September 01, 2007

Java Lessons - part 1

My java learnings for the day -
1. Always implement toString - It seriously is a pain for otherwise to decode the object.
2. Be aware of memory leaks! Nullify object references when required but NOT always. At times trust the garbage collector ;).
3. Evaluate static factory methods vs. constructors.
4. Singletons are a great way to ensure single object instance.
5. Object creation is costly! It hurts performance many times over. Create only when you should.

1 comment:

Pallavi said...

Yes. One should aware of memory leaks. I used to get problem with ResultSet always. I used to open it but never closed. I did this twice in two years gap and spent more time in debugging. Now, I won't repeat the same. :)