Reputation
2,905
Top tag
Next privilege 3,000 Rep.
Cast close & reopen votes
Badges
13 30
Newest
 Yearling
Impact
~137k people reached

Jun
12
comment Why is Python written in C and not in C++?
@hyde And also against C++ programmers at the time :P
Jun
12
comment Why is (position < size) such a prevalent pattern in conditionals?
Might be related to how intervals are written [min, max] and not [max, min]. Therefore, it's only natural to check than an element x belongs to the interval by writing min <= x <= max.
Jun
11
comment c#/java or c++ (Personal question)
You enjoy C#? It seems you've answered your own question. By the way, please read the FAQ: you'll see questions here should apply to all programmers, therefore a "personal question" is probably too localized :)
Jun
7
comment Why does PHP have interfaces?
@YamMarcovic Here's an example: Haskell is a statically typed language (with a stronger type system than PHP and the usual 'static' OOP languages) and it has no nulls. Therefore, you cannot pass null to a function. A whole family of bugs goes away as soon as the compiler statically assures that yes, you are getting a value, and not null. You can use the Maybe monad for "optional" values, but it doesn't work like null in unsafe languages, and it can never surprise you.
Jun
6
comment Passing member variable as a method parameter
@Tarion I disagree with Uncle Bob on this. Whenever possible, methods should be function-like and only depend on explicit dependencies. (When calling public methods in OOP, one of these dependencies is this (or self), but it's made explicit by the call itself, obj.method(x)). Other implicit dependencies are the object's state; this usually makes code harder to understand. Whenever possible -- and within reason -- make dependencies explicit & functional-style. In the case of private methods, if possible, explicitly pass every parameter they need. And yes, it helps to refactor them out.
Jun
4
comment I don't understand how TDD helps me get a good design if I need a design to start testing it
@Giorgio Fully agreed! I do see some value in TDD, just not if blindly followed. But isn't this a trap Ron Jeffries himself, one of Agile/TDD's famous proponents, fell into? And if he made this mistake (hey, we are all human!), shouldn't he acknowledge it so less experienced TDD practicioners don't fall into the same trap?
Jun
3
comment Is this pattern bad?
@DocBrown If those internal details can be generalized in order to be used in multiple components, then you extract them to a separate component, complete with its own unit tests. Again, you never directly test private methods.
Jun
3
comment Is this pattern bad?
@DocBrown It's not the same as saying integration tests make unit tests needless. Integration tests exercize the "connectivity" between separate components; in contrast, unit tests exercisze the local logic of a single component thoroughly (corner cases, etc.). Integration and unit tests don't exercize the same scenarios! However, a good unit test doesn't need to test private implementation details, just the public API. If thoroughly testing the public API doesn't give you coverage of internal details, then those details aren't being used, and are therefore dead code.
Jun
2
revised What is early and late binding?
redacted for clarity
May
31
comment Making Simple IF Statements Shorter
This is like saying "let's not use scalpels for surgery, because non-surgeons might not understand them. Let's use kitchen knives instead! They are easier, and everyone has them!"
May
31
comment Making Simple IF Statements Shorter
@emory Sorry, that's simply not true. The only people who should look at the code are the people who can understand it. Never in my career have I seen non-technical people trying to understand source code (as opposed to requirements, diagrams, etc). In any case, my argument is that return booleanExpr; is TONS simpler than if (booleanExpr == true) { return true; } else { return false; }. It's hard to argue the opposite, even for "non-technical people"; because for them, what do all those extraenous if, {, else and } add?
May
31
awarded  Nice Answer
May
31
comment Making Simple IF Statements Shorter
It's a good practice. Also, it's like the FizzBuzz test: any programmer who claims boolean expressions are "difficult to understand" and that "gets it backwards" unless "they are spelled out in a 'long-form' if" should be a NO HIRE. Think about it: if they can't handle this complexity, would you trust them with fixing a problem in production?
May
31
comment Making Simple IF Statements Shorter
PS: I'd be terribly scared of your coworkers who "got the logic backwards". Were there no code reviews? No tests? Did they get fired? Did anyone got fired at your company for incompetence, at all?
May
31
comment Making Simple IF Statements Shorter
Aaargh! A boolean expression is not "clever"; it's programming 101! Here, an even clearer longer form for you: if (cond == true) { return true == true; } else if (cond == false) { return true == false; } else { return FILE_NOT_FOUND; }. It's longer, so it must be clearer!
May
31
comment Making Simple IF Statements Shorter
People confused by boolean expressions should be educated. If after being taught about them they are still confused, they have no right to be programmers. But no, the needlessly verbose if is never the right answer. (Likewise, you shouldn't stop writing for each in Java simply because some inexperienced programmer is still unfamiliar with them).
May
31
comment Making Simple IF Statements Shorter
+1000 to this answer (if I could). It indeed indicates lack of understanding of boolean expressions. Also, the longer form is never "clearer". No amount of {, } or ; will make a simple boolean expression "clearer". Everyone: please stop equating clarity with needless verbosity.
May
30
comment Does Turing-complete implies possibility of malware?
@Mathematician82 But here on stackexchange anyone can edit text anyway. Seriously, do your work. Show some effort.
May
30
comment Phonetic programming language?
possible duplicate of Is programming language that is non-visual … possible?
May
29
comment I don't understand how TDD helps me get a good design if I need a design to start testing it
@Giorgo, RobertHarvey: +1000 to RobertHarvey from me as well. Unfortunately, that misconception is common enough that some "expert" TDD/Agile practitioners believe it to be true. Like for example, they pretend you can "evolve" a sudoku solver out of TDD, without domain knowledge or analysis of any kind. I wonder if Ron Jeffries ever published a follow-up on the limitations of TDD or explained why he suddenly stopped his experiment without any conclusions or lessons learned.