[OSM-dev] Josm-patches and osm-lib was:OSM Date Formats

Dave Stubbs osm.list at randomjunk.co.uk
Wed Oct 3 14:26:32 BST 2007

On 03/10/2007, Brent Easton <b.easton at exemail.com.au> wrote:
> *********** REPLY SEPARATOR  ***********
> On 3/10/2007 at 10:39 AM Martijn van Oosterhout  wrote:
> >On 10/2/07, Shaun McDonald <shaun at shaunmcdonald.me.uk> wrote:
> >> Having public parameters is completely against everything I've been
> >> taught in my 4 year Computer Science degree. If you have public
> >> getters and setters for all required properties then there is nothing
> >> that you cannot do, that you can do with public properties. There are
> >> often properties that you don't want any old person to come along and
> >> modify, thus the use of getters and setters.
> >
> >If you don't want people to use them then you declare them private.
> >There's not really any difference between a public member and a pair
> >of getters/setters for a private member.
> Well, actually, there is a large difference Martin. One of the basic tenets of OOP is 'information hiding' where the lower level data structures are hidden from the higher level parts of the program that use them.
> Using a public member forces the higher level routines to have to 'know' about the details of the implementation of the lower level. If you suddenly decide to swap out structure A with indexed structure B, you can happily do this and just update the getter/setters, knowing that all of the code that has already been written is accessing the information through the getter/setters and other public interface routines and will continue to work without change. On the other hand, having plugins access public members directly means that when you make changes, you have to go back and modify and recompile all of the plugins.

Yes, and one of the biggest day-to-day implications of that is that
testing becomes incredibly difficult... if you're programming to an
interface then you can mock objects with relatively little problem,
but if there are public attributes everywhere then this becomes
impossible and tests become harder to write. A consequence of that in
a project like this is probably that tests just aren't written.

In other OO languages (ie: ruby for one) attributes aren't necessarily
simple object variables, so this isn't an issue for them.

I don't know how the public attributes have been used in JOSM. It may
actually have very little impact in reality.

More information about the dev mailing list