søndag den 17. juni 2007

Sunday java code guidelines

Avoid using static references.

You are making the code dependent on implementation of a function. This does not scale well. It puts your program at risk because a reference somewhere else might require the implementation to change, without the ability to abstract it by polymorphism.

You can use dependency injection to achieve this.. see Guice f.ex.

Use the final keyword as much as possible.

this reduces the chance that you will change the state of an object inadvertently, greatly stabilizing your code as the program evolves and become larger.