Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Java "best practices" book?

Status
Not open for further replies.

cpjust

Programmer
Sep 23, 2003
2,132
0
0
US
Hi,
I was wondering if anyone knows of any good books for Java that teaches best practices when programming in Java?

I absolutely love this book:
but it's for C++. Would many (any) of the rules in that book also apply for Java?

Some examples in the C++ book that I'm wondering if they apply for Java would be things like:

Chapter 34. Prefer composition to inheritance.
Chapter 35. Avoid inheriting from classes that were not designed to be base classes.
Chapter 37. Public inheritance is substitutability. Inherit, not to reuse, but to be reused.
Chapter 39. Consider making virtual functions nonpublic, and public functions nonvirtual.
Chapter 49. Avoid calling virtual functions in constructors and destructors.
Chapter 57. Keep a type and its nonmember function interface in the same namespace.
Chapter 58. Keep types and functions in separate namespaces unless they're specifically intended to work together.
Chapter 64. Blend static and dynamic polymorphism judiciously.
Chapter 76. Use vector by default. Otherwise, choose an appropriate container.
Chapter 81. Prefer range operations to single-element operations.
Chapter 90. Avoid type switching; prefer polymorphism.
Chapter 91. Rely on types, not on representations.
Chapter 100. Don't treat arrays polymorphically.
 
Thanks. I saw that book while looking through the javapractices site. It sounds good, but I'll wait until the 2007 edition comes out.

Some of what I read on javapractices.com seems reasonable to me, although sometimes I see contradictions or not enough information in a section to make a compelling case to use what it suggests.
That's why I like those "Effective ... Programming" books better than random sites online that could have been written by a kid for all I know.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top