[josm-dev] Jumbo Patch

Frederik Ramm frederik at remote.org
Sun Dec 16 00:30:17 GMT 2007


Hi,

>> 3. I don't like the privatisation because it bloats the code: You
>> have to implement a ton of accessors and they all just "pass
>> through" stuff, only a tiny percentage actually does something
>> different. But that's the Java spirit probably...

> Thats not just about the "java spirit". Correct encapsulation can save you
> a lot of headaches just for few lines of code (I certainly won't call
> a getter "bloat" and hotspot even inlines the code).

I know the basic ideas & advantages behind encapsulation. Hotspot
inlining stuff removes the runtime cost of it, but the code bloat
remains; for everything that might have to be accessed from the
outside, you need a getter and setter - and they carry *no* additional
information, except the tiny percentage of getters and setters where
you actually do something other than just reading or writing a private
variable.

I'm not against encapsulation per se. I perfectly understand that
properly encapsulating stuff gives you the option of transparently
introducing changes later. I am just against the fact that whereever 
you look, 50% of code is some auto-generated

/**
 * Gets the blah.
 *
 * @return the bla.
 */
public Blah getBlah() {
   return blah;
}

(It's even worse when not auto-generated.)

Just as Hotspot inlines the stuff, the compiler could easily generate
this on the fly where required so that I only have to explicitly write
those methods where something happens. 

The issue was exemplified by Dave's patch where he just wanted control
over a tiny bit of all possible operations on the node list, but for
this paid the price of adding getters and setters for near everything.
If that isn't bloat, then what is?

I don't know which of the en-vogue programming paradigms this was but
there is one that basically says "don't over-engineer, just write
exactly the code you need to solve the problem at hand". I would like
to be able to do that, write exactly the code required, instead of
using 50% of my code lines to pave the way for something that might
come in handy later. Or might not.

Bye
Frederik

-- 
Frederik Ramm  ##  eMail frederik at remote.org  ##  N49°00.09' E008°23.33'





More information about the josm-dev mailing list