[josm-dev] Spaghetti code

Igor Shubovych igor.shubovych at gmail.com
Wed Feb 4 23:58:24 GMT 2009


2009/2/5 Stephan <osm at stephans-server.de>

> Igor Shubovych wrote:
>
>> I really do not want to abuse anybody, but ... this is spaghetti code.
>> ...Almost everywhere in JOSM.
>>
>
>
> Quote from wiki (imi):
> http://josm.openstreetmap.de/wiki/DevelopingPlugins
>
> First some words about my style of accessing public variables. Most people
> find this annoying and bad coding style in Java. If this would be an
> enterprise project, where most of the code is glue code and had to work with
> objects in a generic way, I would agree with them. But as JOSM is not, I
> like to keep the classes as simple as possible, which includes, that I don't
> add standard getter/setter but make the variable public.


I don't vote for getter/setter stuff, but for encapsulation. IMHO labels and
buttons are internal implementation stuff. They should be private. And class
should provide some public primitive API. That's it.

Also, there are no or very few so-called singleton-factories in JOSM that
> became popular in the past years. I use to reference singleton objects as
> global statics. This is unusual but equivalent to having stuff like
> Dependency Injection or Factory Methods (except you want to make complex
> things like auto-distributing stuff as seen in some enterprise programs).


Well this is also not good in all ways, but ok, if
org.openstreetmap.josm.Main provide some API.
Bad example: Main.somePanel.someLabel.setText("BlaBlaBla");
Good example: Main.somePanel.doSomeStuff("BlaBlaBla");


>
>
> Most objects are accessible through the class org.openstreetmap.josm.Main.
> There are numerous entry points for various parts of JOSM here.
>
>
>
>
> Stephan
>

Regards,
Igor Shubovych



More information about the josm-dev mailing list