Chapter 8. Object-Oriented Techniques
Java is an Object-Oriented (OO) language in the tradition of Simula-67, SmallTalk, and C++. It borrows syntax from C++ and ideas from SmallTalk. The Java API has been designed and built on the OO model. Design patterns (see the book of the same name), such as Factory and Delegate, are used throughout; an understanding of these patterns will help you better understand the use of the API and improve the design of your own classes.
Advice, or Mantras
There are any number of short bits of advice that I could give. A few recurring themes arise when learning the basics of Java, and I suggest reviewing them when learning more Java.
Use the API
I can’t say this often enough. A lot of the things you need to do have already been done
by the good folks who develop the standard Java library (and third-party libraries).
And this grows with every release. Learning the API well is a good grounds for avoiding that deadly “reinventing the flat tire” syndrome—coming up with a second-rate equivalent of a
first-rate product that was available to you the whole time. In fact, part of this book’s
mission is to prevent you from reinventing what’s already there. One example of this is
the Collections API in
java.util, discussed in Chapter 7. The Collections
API has a high degree of generality and regularity, so there is often no need
to invent your own data structuring code.
Exceptions to the rule
There is one exception to the rule of using the ...