Designing with Objects
By Al Williams
I've noticed as I teach classes that many programmers are rusty when it comes to doing traditional tasks. They often get wrapped up in user-interface jobs, like those that require event handlers and layout managers. Those jobs make it easy to skip core techniques, or forget them altogether.
More and more programmers are writing code for the server, where the user interface is practically nonexistent. If you find yourself focusing on algorithms instead of user interfaces, you might want to spend some time brushing up on object-oriented design skills. After all, most user-interface development consists of using Abstract Window Toolkit (AWT) or Swing classes, whereas server-side work often requires you to develop your own class hierarchies.
You can always put together a quick-and-dirty class definition, but a well-planned one makes your code more robust, easier to build, and simpler to maintain. In short, a properly designed program can make all the difference between success and virtual disaster. And don't be fooled thinking object-oriented design applies only to languages like Java or C++. As I'll show you later, you can create objects in JavaScript, too.
What's an Object?
The idea here is to get back to basics, so let's start right at the beginning. What's an object? In simple terms, an object is an entity that has "state," meaning that it can store information across sessions; the information isn't lost or reset each time your program code refers to the object.
An object can perform operations on itself, via methods or functions.