Chapter 5. Objects in Java
In this chapter, we’ll get to the heart of Java and explore the object-oriented aspects of the language. Object-oriented design is the art of decomposing an application into some number of objects—self-contained application components that work together. The goal is to break the problem down into a number of smaller problems that are simpler and easier to understand. Ideally, the components can be implemented as straightforward objects in the Java language. And if things are truly ideal, the components correspond to well-known objects that already exist, so they don’t have to be created at all.
An object design methodology is a system or a set of rules created to help you identify objects in your application domain and pick the real ones from the noise. In other words, such a methodology helps you factor your application into a good set of reusable objects. The problem is that though it wants to be a science, good object-oriented design is still pretty much an art form. While you can learn from the various off-the-shelf design methodologies, none of them will help you in all situations. The truth is that there is no substitute for experience.
We won’t try to push you into a particular methodology here; there are shelves full of books to do that.[17] Instead, we’ll provide a few hints to get you started. Here are some general design guidelines, which should be taken with a liberal amount of salt and common sense:
Think of an object in terms of its interface, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access