2,871 reputation
1330
bio website
location Argentina
age 38
visits member for 4 years, 3 months
seen 7 hours ago

Software developer and science fiction fan.


Jun
13
comment What did Rich Hickey mean when he said, “All that specificity [of interfaces/classes/types] kills your reuse!”
@GlenPeterson Yes, you are right. Or rather, instead of "dynamic" (which do assign "named" types to the value) I'd say "languages with structural typing", such as Clojure. Note that what you suggest, rather than a full-blown solution is actually a trade-off; what you gain in flexibility you lose in type safety (which is what static typing addresses!). BTW, I'm no expert and might have got the details wrong ;)
Jun
12
comment What features should a programming language have to say it has good reusability?
OOP is by no means a requirement for code reuse.
Jun
12
comment Why is Python written in C and not in C++?
@ott Indeed, that question does make sense: why isn't the standard implementation of Python written in Python? It follows that the designer of Python likes his own language, so the question is interesting.
Jun
12
comment Why is Python written in C and not in C++?
@PiotrDobrogost That's a strawman. It's obvious why you wouldn't want to write modern, non-performance critical code in assembly. Your question is different though: "why C instead of C++?". Let me reverse the question: "why C++ instead of C?". Or worse: "why C++ and not Pascal. I like Pascal more!"
Jun
12
comment Why is Python written in C and not in C++?
I fail to see the point of asking "why is (popular program) written in (language X) and not (language Y)?". Or rather, the same question can be reversed: why Y and not X?
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!