Saturday, October 31, 2009

Why We Do What We Do

I have recently been reading a great book titled Effective Java by Joshua Bloch. I'm only part way through it but it has really clarified a number of things for me. I have been writing Java code for over a decade now and there are many things that I do just because it feels right but if I had to articulate why, I would have to think real hard about it. In this book Josh does an excellent job explaining the why behind good programming practice and style.

To give an example, I have never used the clone method that hangs on Object. I always used a copy constructor in favor of clone. I'm not sure why but probably because that's how most people in the Java community do it and it works well. Well "item 11 - Override clone judiciously" goes into great detail about the problems and complexities of using clone and why using a copy constructor is usually (but not always) a better way to go.

Going through this book is giving me a better understanding of why we do what we do!