Know your Object's Heritage
Creating new classes in Java is easy… but classes you create have a lot of inherited behavior that may or may not be what you need. There are also a lot of useful capabilities in the standard Java libraries that you may want to give your objects. Unfortunately, developers transitioning from other languages often don't discover these language features until some related problem bites them. The concepts here aren't sexy, but you will probably learn something that will make you go want to fix code in your current project.
In this session we will cover:
- Reasons for and pitfalls when implementing your own equals() and hashCode() methods
- Best practices for object construction (Factories and Immutability)
- Useful toString() idioms
- Serializable, Externalizable, and custom serialization techniques using the 'hidden' methods of Serializable
- Clonable, shallow and deep copies, and why Clone() is evil.
- Comparators and the Comparable Interface
- Finalize(), and why not to use it
- Your class's 'Class' object: opening the door to reflection.
- Leaky references to 'this'
- Guidelines for building objects in inheritance hierarchies
- Many other useful practices and idioms
- Tools to help you find and fix problems like these
About David Bock
David Bock is a Principal Consultant at CodeSherpas, a company he founded in 2007. Mr. Bock is also the President of the Northern Virginia Java Users Group, the Editor of O'Reilly's OnJava.com website, and a frequent speaker on technology in venues such as the No Fluff Just Stuff Software Symposiums.
In January 2006, Mr. Bock was honored by being awarded the title of Java Champion by a panel of esteemed leaders in the Java Community in a program sponsored by Sun. There are approximately 100 active Java Champions worldwide.
David has also served on several JCP panels, including the Specification of the Java 6 Platform and the upcoming Java Module System.
In addition to his public speaking and training activities, Mr. Bock actively consults as a software engineer, project manager, and team mentor for commercial and government clients.
More About David »