[OSM-dev] java applet reformatted

Tom Carden tom at tom-carden.co.uk
Tue Feb 21 18:15:06 GMT 2006


On 2/21/06, Immanuel Scholz <immanuel.scholz at gmx.de> wrote:
> Hi,
>
> I finished reformatting and commenting the applet.

Good for you!  I hope it wasn't too scruffy!  (Reformatting sounds
like a waste of time to me personally, unless it was mainly to let you
figure out how everything works).

>
> For future editing of the java applet, I want YOU to respect some of the
> java coding standards ;-)
>
> - Tab size is 4

Mine is 8 :p  It's 2 in Processing, which is where the applet originates.

> - For naming, abbreviations are treated like words. GpxParser, not
> GPXParser. OsmApplet, not OSMApplet etc...

That seems completely arbitrary to me.  I prefer the way we had it before.

> - Javadoc comments are cool!

Sure, I suppose they are.

> - Dead code stinks! Remove it instead of comment it out. It can be revived
> from Subversion anyway.

Not if you reformat everything so the line numbers are different and
the files are renamed! ;)

But actually, I'd argue that dead code can be a good form of
documentation whilst things are under active development.  Like "I
tried it this way, but that didn't work" or "we used to do it this
way", etc.

>
> Some tecnical hints:
>
> - Use base classes or interfaces instead of the concrete objects, if
> possible. Collection instead of Vector, Map instead of Hashtable...

This is OOP class now, and not OSM?  Really!  What about things like
Vector is synchronised by default, so it can't just be swapped out for
a standard ArrayList?  These things aren't always interchangeable.

Also, Collection isn't necessarily orderered, so I would say use List
there instead of Vector if you must.

> - Use the most restricting modifier that fit. "private" is more
> restricting than no modifier at all (default).

Is the default modifier protected then? (Or is it package... I'll look
it up). I thought it was private but I stand corrected.

> - Iterator is better than Enumeration.
>

Yeah, but if an Enumeration is used then it means Steve wrote that bit
of the code :)  Seriously, that can actually be pretty useful.  If you
over-zealously enforce your coding standards, you neglect the fact
that the code base is somewhat organic and that collaborations have
tell-tale signs that help them function more efficiently than
rigourous formatting ever can.

Just my 2 euro-cents.  Don't take me too seriously, since I'm actually
really glad you're hacking on the applet.  Steve and I benefitted from
meeting up in person a lot whilst the applet was being developed - we
don't have that luxury with you, but feel free to ask if you want to
bounce ideas around, and let us know what you're up to.

Best,

Tom.




More information about the dev mailing list