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.
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.