Re:Coding Skill and the Decline of Stagnation
by pigs on Friday January 13, 2012 @03:48PM
(#3462328)
Joshua Bloch in Effective Java argues that the java bean is an anti-pattern and should be avoided.
Re:Coding Skill and the Decline of Stagnation
by Roboprog on Friday January 13, 2012 @05:29PM
(#3462676)
Oh thank God somebody in authority is calling this bean bull_hit what it is.
After reading the Eiffel book and thinking about things like programming by contract and class invariants, the bean pattern which constructs empty, initially useless (or at least unreliable) objects seemed like a huge step back.
Re:Coding Skill and the Decline of Stagnation
by figglesonrails on Friday January 13, 2012 @04:07PM
(#3462406)
Cool story, bro.
(Mime aside, do we get to hear what the argument was?)
Re:Coding Skill and the Decline of Stagnation
by pigs on Friday January 13, 2012 @04:55PM
(#3462568)
The crux of the argument (and most of the book for that matter) is that you want to avoid mutability whenever possible. Adding setters for every field by default means mutability is the default mode for your application. Adding getters for every field by default means you lose any advantages of encapsulation.
At one time, Java Beans were a heavily marketed pattern by Sun. Joshua Bloch came along and said "hey, this is a bad pattern" (and maybe others, but he's the one I always think of).
Re:Coding Skill and the Decline of Stagnation
by jiggy2011 on Friday January 13, 2012 @05:35PM
(#3462698)
Why does everything have a getter/setter by default?
That is a pretty horrible anti-pattern, is it something to do with being able to serialise the state (including internal state) of the whole object?
Re:Coding Skill and the Decline of Stagnation
by hackinthebochs on Friday January 13, 2012 @09:30PM
(#3463302)
It's about hiding implementation. If you access an object only through methods then the implementation can change without the client code having to know or care (aka be recompiled)
But yeah, its a bunch of ridicules, generated spam.