|
JawnV6 posted:If you look around and there's not anyone to learn from: leave. Keep in mind that it doesn't have to be a learning within your field at all. One of the things that makes Red Hat such a great place to work at is because we're fairly well diversified. On my floor, I can talk to people who are experts in GPU technology and write GPU drivers and OpenGL implementations. Or I can talk to the guys who make your mouse and keyboard work and why all input hardware is terrible. Or why your windows never seem to resize correctly. Or how text rendering is a mess. Or walk a floor up and learn about how video/audio compression and how codecs work. Hm, maybe I should learn about compilers today. Hm, or not, maybe networking. Holy crap, I never knew rebooting a computer was this complicated. I don't have any blog posts to link to, but I also talk with the sales/business people a lot. In fact, that's probably who I'm learning most from right now. They make great lunch partners, and I love hearing about all the social problems they have to solve as well, in their own little domain.
|
# ? Mar 27, 2014 03:45 |
|
|
# ? May 17, 2024 15:09 |
|
Flownerous posted:int or float? I use that form if it's a float and I want to catch NaN too. Maybe I'm the horror? How is !(NaN > 0) any more defined than (NaN > 0)?
|
# ? Mar 27, 2014 04:59 |
|
Bizarro Buddha posted:How is !(NaN > 0) any more defined than (NaN > 0)? All comparisons with NaN are false, so they're both equally defined, yes. But the value of the expression is obviously different. !(a > 0) is true for positive and negative zero, negative numbers, and NaNs. a <= 0 is true for positive and negative zeroes, and negative numbers but not NaNs. (Assuming non-signaling NaN, of course.)
|
# ? Mar 27, 2014 05:11 |
|
It's the same function, with the Dev's name for the second one.php:<? I have a web team meeting tomorrow. And, I may go to prison for murder. So long goons. [php] /** * Static content controller. * * This file will render views from views/pages/ * * CakePHP(tm) : Rapid Development Framework ([url]http://cakephp.org[/url]) * Copyright (c) Cake Software Foundation, Inc. ([url]http://cakefoundation.org[/url]) * * Licensed under The MIT License * For full copyright and license information, please see the LICENSE.txt * Redistributions of files must retain the above copyright notice. * * @copyright Copyright (c) Cake Software Foundation, Inc. ([url]http://cakefoundation.org[/url]) * @link [url]http://cakephp.org[/url] CakePHP(tm) Project * @package app.Controller * @since CakePHP(tm) v 0.2.9 * @license [url]http://www.opensource.org/licenses/mit-license.php[/url] MIT License */ App::uses('AppController', 'Controller'); /** * Static content controller * * Override this controller by placing a copy in controllers directory of an application * * @package app.Controller * @link [url]http://book.cakephp.org/2.0/en/controllers/pages-controller.html[/url] */ class PagesController extends AppController { /** * This controller does not use a model * * @var array */ public $uses = array(); /** * Displays a view * * @param mixed What page to display * @return void * @throws NotFoundException When the view file could not be found * or MissingViewException in debug mode. */ public function display() { $path = func_get_args(); $count = count($path); if (!$count) { return $this->redirect('/'); } $page = $subpage = $title_for_layout = null; if (!empty($path[0])) { $page = $path[0]; } if (!empty($path[1])) { $subpage = $path[1]; } if (!empty($path[$count - 1])) { $title_for_layout = Inflector::humanize($path[$count - 1]); } $this->set(compact('page', 'subpage', 'title_for_layout')); try { $this->render(implode('/', $path),'cake-default'); } catch (MissingViewException $e) { if (Configure::read('debug')) { throw $e; } throw new NotFoundException(); } } /** * Displays a view * * @param mixed What page to display * @return void * @throws NotFoundException When the view file could not be found * or MissingViewException in debug mode. */ public function developersName() { $path = func_get_args(); $count = count($path); if (!$count) { return $this->redirect('/'); } $page = $subpage = $title_for_layout = null; if (!empty($path[0])) { $page = $path[0]; } if (!empty($path[1])) { $subpage = $path[1]; } if (!empty($path[$count - 1])) { $title_for_layout = "DeveloperName: ".Inflector::humanize($path[$count - 1]); } $this->set(compact('page', 'subpage', 'title_for_layout')); try { //$this->layout = 'default_developersName'; $this->render(implode('/', $path),'default'); } catch (MissingViewException $e) { if (Configure::read('debug')) { throw $e; } throw new NotFoundException(); } } } ?> substitute fucked around with this message at 02:31 on Mar 28, 2014 |
# ? Mar 27, 2014 08:09 |
|
Gazpacho posted:memset(out, NULL, bufSize); The worst thing is passing NULL to memset.
|
# ? Mar 27, 2014 08:14 |
|
leper khan posted:if (!(foo > 0)) { There's a number of IBM things which support all eight relational operators: EQ, NE, LT, LE, GT, GE, NL and NG. The latter two meaning "not less than" and "not greater than".
|
# ? Mar 27, 2014 13:48 |
|
What happened to NGE and NLE? Seems like an embarrassing oversight!
|
# ? Mar 27, 2014 14:25 |
|
shrughes posted:The worst thing is passing NULL to memset. The code is initializing an array of pointers to NULL. It's odd, but I'm not totally against it.
|
# ? Mar 27, 2014 14:54 |
|
contrapants posted:The code is initializing an array of pointers to NULL. It's odd, but I'm not totally against it. memset operates on bytes, not words, so passing something with pointer-meaning is pretty broken. In many C (rather than C++) environments it wouldn't compile, because NULL is (void *)0 rather than C++'s simple 0.
|
# ? Mar 27, 2014 15:02 |
|
Subjunctive posted:memset operates on bytes, not words, so passing something with pointer-meaning is pretty broken. In many C (rather than C++) environments it wouldn't compile, because NULL is (void *)0 rather than C++'s simple 0. You're right about that. I was thinking more along the lines of "at least I can tell what he's trying to do here" rather than what's actually correct. Maybe the code at my job has made me too lenient to bad code. code:
Nothing compiles unless if it is specifically passed to the preprocessor as a separate stage in the Makefile. I have no idea why yet. edit: Missed a variable name Marta Velasquez fucked around with this message at 15:18 on Mar 27, 2014 |
# ? Mar 27, 2014 15:15 |
|
Suspicious Dish posted:Interesting links thanks for these. one underlying theme im spotting is that hardware developers seem to hate software. and not in an ironic "haha software sucks, coding horrors amirite?" way- but a proper "everything should be hardware" way. is that actually a thing?
|
# ? Mar 27, 2014 15:21 |
|
contrapants posted:Every variable starts with a J, because Jesus should be in everything. Is that... is that really the reason?
|
# ? Mar 27, 2014 15:22 |
|
SavageMessiah posted:Is that... is that really the reason? I swear that it is. Another product requires a copy of the Windows registry be exported to it as a tree of plain text files. This product runs Android. I wish I could just dump the entire repo into this thread. I've learned to pick my battles during code reviews. The memset to NULL compiles, so I wouldn't have fought it. There are worse errors to fight about.
|
# ? Mar 27, 2014 15:30 |
|
I've got somebody's hand-rolled graph algorithm code that I don't trust and now I have to decide between digging through it to debug it or just rewriting everything using a proper library and hoping they weren't doing anything intentionally weird. Unit tests or documentation? What are those?
|
# ? Mar 27, 2014 18:51 |
|
Gazpacho posted:
For that to compile presumably there's a using namespace std; in there somewhere. Which is also horrible
|
# ? Mar 27, 2014 19:43 |
|
leper khan posted:if (!(foo > 0)) { Not sure I understand this one? (-1 is true in Calikes, remember, so this is 'do this if the value is 0 or negative', which seems fair enough)
|
# ? Mar 27, 2014 19:46 |
|
Two related links for consideration: https://github.com/kohsuke/github-api/blob/master/src/test/java/org/kohsuke/AppTest.java#L76 https://github.com/kohsuke/test/issues?state=closed
|
# ? Mar 27, 2014 19:52 |
|
feedmegin posted:Not sure I understand this one? (-1 is true in Calikes, remember, so this is 'do this if the value is 0 or negative', which seems fair enough) It would be a lot more readable as if (foo <= 0), though.
|
# ? Mar 27, 2014 19:54 |
|
feedmegin posted:For that to compile presumably there's a using namespace std; in there somewhere. Which is also horrible NtotheTC posted:thanks for these. one underlying theme im spotting is that hardware developers seem to hate software. and not in an ironic "haha software sucks, coding horrors amirite?" way- but a proper "everything should be hardware" way. is that actually a thing? What SD described is a benefit of working in any company that produces a general-purpose OS stack.
|
# ? Mar 27, 2014 20:17 |
|
Steve French posted:Two related links for consideration: does that mean his github credentials are in the baseline...? nm I read it wrong. I wonder if it was even meant as a test or if it's backdoor to list everyone who has built jenkins. Dren fucked around with this message at 21:43 on Mar 27, 2014 |
# ? Mar 27, 2014 21:40 |
|
Y'know, I think this line works remarkably well without further context:code:
|
# ? Mar 28, 2014 04:04 |
|
One horror per side of the equals sign is an excellent ratio!
|
# ? Mar 28, 2014 04:47 |
|
I don't know, guys. Doubling my balance sounds like a great idea!
|
# ? Mar 28, 2014 11:59 |
Six months into the PHP project for a client, we're a few days away from finishing, and one of the guys is like "empty? What does that do.. Can't I just do if($var = null || $var = "") ?"
|
|
# ? Mar 28, 2014 12:34 |
|
It's an oldie, but it never really gets old, does it?code:
|
# ? Mar 28, 2014 18:48 |
|
Well, at least it isn't:code:
|
# ? Mar 28, 2014 19:09 |
|
I'm working on a big project at work and noticed a variation of this being used in the code in multiple places.code:
code:
|
# ? Mar 29, 2014 10:37 |
|
Howmuch posted:I'm working on a big project at work and noticed a variation of this being used in the code in multiple places. This is probably being done to facilitate unit testing. I think it's usually overkill, personally, but there are cases where it makes sense. Suppose for example that you have a method with a test like if (DateTime.Today.DayOfWeek == DayOfWeek.Monday) { ... }. How would you write a unit test for that if you can't override the value of DateTime.Today? Run it only on Mondays? There are a number of ways to deal with this issue, one of which is to hide DateTime.Now behind an interface and inject a mocked implementation in unit tests. Now, if they're doing this but there are no actual unit tests to take advantage of it, then that's certainly the worst of both worlds.
|
# ? Mar 29, 2014 11:34 |
|
LOOK I AM A TURTLE posted:unit testing. Hopefully it was made with unit testing in mind but in comparison with the rest of code from this person I seriously have my doubts. Like the ~1800 line class on the DAL layer whose only purpose is to enable CRUD for one table in the database.
|
# ? Mar 29, 2014 12:04 |
|
Howmuch posted:Nope. Probably a cargo cult thing, then. Or an "I'll definitely write tests for this. Later." thing.
|
# ? Mar 29, 2014 12:46 |
|
Digging through some legacy databases:code:
|
# ? Mar 29, 2014 15:33 |
|
LOOK I AM A TURTLE posted:Probably a cargo cult thing, then. Or an "I'll definitely write tests for this. Later." thing. That seems likely. I've written almost identical code before, but that's because I was writing unit tests. Of course, at this point I prefer to skip the boilerplate for such a simple case and just inject a Func<DateTime> into the class, with the default being () => DateTime.Now.
|
# ? Mar 29, 2014 17:51 |
|
Howmuch posted:I'm working on a big project at work and noticed a variation of this being used in the code in multiple places. How is this a horror at all?
|
# ? Mar 29, 2014 19:18 |
|
It seems reasonable that people would want a MockTimeService for testing.
|
# ? Mar 29, 2014 21:33 |
|
return0 posted:How is this a horror at all? I'm most likely the horror. It's absolutely not horror when you have testing in place or planned("we do not have time for unit testing"). I think I managed to post the worst(best actually) snippet after spending an hour going through that mess. I should have posted one of the 200+ line long functions that had max two character long variable names(a, aa, x, xx, y, yy and so on) and multiple nested loops.
|
# ? Mar 29, 2014 22:09 |
|
shrughes posted:It seems reasonable that people would want a MockTimeService for testing. Indeed. What if you're implementing functionality regarding national holidays and you want to block something from occurring on that date?
|
# ? Mar 29, 2014 22:26 |
|
ToxicFrog posted:It would be a lot more readable as if (foo <= 0), though. Except, as people discussed, that returns a different value if foo is NaN.
|
# ? Mar 30, 2014 04:48 |
|
PleasingFungus posted:Except, as people discussed, that returns a different value if foo is NaN. Yes, in this case changing it to that would have it produce the correct value if foo is NaN.
|
# ? Mar 31, 2014 05:17 |
|
return0 posted:How is this a horror at all? A better option would be what Ithaqua mentioned (pass in a Func) but you could also, you know, have methods that accept a DateTime as input instead of having to inject some kind of nonsensical DateTimeProvider.
|
# ? Mar 31, 2014 09:29 |
|
|
# ? May 17, 2024 15:09 |
|
Dependency injection is actually pretty cool, but it's actually much cooler to use a proper DI framework instead of hand-rolling that sort of thing. There's no reason to have a CurrentTimeService, it should just be a Provider<DateTime> with an annotation that says it provides the value of "now". Having the current time being passed in as a method parameter is also workable, but it's really just pushing your own dependencies up to whoever's calling you, and often just results in even more boilerplate (or untestable code) being written elsewhere to accommodate it. It's really a case-by-case thing as to which is preferable.
|
# ? Mar 31, 2014 11:21 |