1,677 reputation
513
bio website inf.puc-rio.br/~hgualandi
location Brazil
age 24
visits member for 3 years, 6 months
seen 2 days ago

Jun
20
comment When decomposing a large function, how can I avoid the complexity from the extra subfunctions?
I don't think this is too different from the version using blocks to separate the subparts (as far as scoping is concerned at least). You gain the advantage I mentioned of passing arguments to the subparts and you avoid the rest of the code from seeing the subparts but there is still the complexity of the subparts being able to call each other that is not present in the undecomposed version.
Jun
20
comment When decomposing a large function, how can I avoid the complexity from the extra subfunctions?
Well, even though global state would make things more complicated this problem also applies to functional languages if you have to do a lot of stuff. I guess going with Haskell style "where" clauses is the way to go.
Jun
20
comment When decomposing a large function, how can I avoid the complexity from the extra subfunctions?
@Ken: Its not always possible to do that though - how do I decompose functions in the general case?
Jun
20
comment When decomposing a large function, how can I avoid the complexity from the extra subfunctions?
@gnat: I think I am dealing with a much more specific issue here though
Jun
19
comment Why are so many languages passed by value?
It could be worse. Some old languages also allowed for call by name
Jun
6
comment If immutable objects are good, why do people keep creating mutable objects?
BTW - even if we ignore the whole mutability vs immutability issue, public getters and setters are a well known source of pain in OO design, since they tend to break encapsulation and invariants.
May
22
comment The “blub paradox” and c++
A note on pattern matching: I wouldnt say its easier to write in general, but after you read a bit on the expression problem it becomes clear that things like if and switch statements, enums and the observer pattern are all inferior implementations of Algebraic Data Types + Pattern Matching. (And lets not even get started on how Maybe makes null pointer exceptions obsolete)
May
22
comment Teaching Programming Concepts Without a Specific Language
Im sure someone, somewhere, must have written an introduction to the RPGMaker language for non-programmers. It will be much easier to move on to more advanced topics once he goes through that.
May
21
comment Why is Invariance, Covariance and Contravariance necessary in typed languages
@JoachimSauer: co/contra variance is an important concept whenever you add subtyping to a programming language, so yes, Id say its "necessary".
May
17
comment How can I apply OOP concepts to building a simple, but real-world, web app?
A rule of thumb I have, specially for dynamic languages, is to try to only create classes if I want to take advantage of polymorphism (that is, if those classes will implement different versions of the same method, and the logic will depend on that somehow). Otherwise, I try to err on writing in a more "procedural" style, in order to keep it simple.
May
10
comment Is it wrong to use a boolean parameter to determine behavior?
@Blrfl: Yes, I think the more straightforward refactorings would be either creating a doOne and doBoth methods (for the false and true case, respectively) or using a separate enum type, as suggested by James Youngman
May
8
comment Where are null values stored, or are they stored at all?
@Neil: You might want to check this entry in the C faq or this SO question
May
7
comment The modern way to perform error handling…
@Giorgio: Checked exceptions don't interact well with the generic system, making it harder to define many sorts of useful higher-order functions. james-iry.blogspot.com.br/2012/02/…
May
7
comment The modern way to perform error handling…
@Giorgio: Its very hard to foresee every kind of exception that a method might throw, since this needs to take into account other subclasses and code that has yet to be written. In practice people end up with ugly workarounds that throw away information, like reusing a system exceptions class for everything or having to catch and re-throw inner exceptions frequently. I have also heard that checked exceptions were a big hurdle when they were trying to add anonymous functions to the language.
May
4
comment Good ways to jump to a particular state in a yielding stateful function?
I don't think your use of goto there is actually that bad...
May
4
comment Refactoring Switch Statements and is there any real use for Switch Statements at all?
Heve you ever heard of the Expression Problem? The OO and the FP are better in different situations, if you stop to think about it.
May
3
comment Is it fair to reduce OOP to mere hierarchical composition of data structures?
@c69: I would say that inheritance and subtype polymorphism are a good way to define object-orientation (ie, if you are using these in your code then you code is object-oriented, regardless of language). However, I agree with you that "encapsulation" and (plain) "polymorphism" are generic terms and can apply to other things too.
May
3
comment The modern way to perform error handling…
Error codes can be easier to use if you have good forms of syntactic sugar or helper methods though, and in some languages you can make the compiler and type-system guarantee that you will never forget to handle an error code. As for the exception interface part, I think he was thinking about the notorious clunkyness of Java's checked exceptions. While they seem like a perfectly reasonable idea at first glance, they cause many painfull little problems in practice.
Apr
11
comment What's wrong with JavaScript
@scrwtp: You are right. I was thinking more about module-level encapsulation though (and the lack of a standard module system)
Mar
26
comment Is it better to learn the DOM or jQuery first?
I can imagine why one might shy away from a string-based DSL like sizzle but come on, the default DOM API is an exercise in pain that I would not wish on my worst enemy.