Components of Object-Oriented Programming04/20/2001
Object-oriented programming is the cornerstone of modern software, including Apple's Mac OS X. The fundamental logical unit of object-oriented programming (OOP) is the class. Think of a class as a tiny sub-program on your computer that exists for one very specialized purpose. You build applications by assembling these classes in a useful way, and directing them to work in concert to accomplish something more complicated. Thus, the sum is greater than the parts.
Building classes to construct an application is very much like building a skyscraper. We know that successful skyscraper construction requires the efforts of many talented individuals. Specialists are needed to pour the concrete, install the electrical systems, fit the plumbing, coordinate the communications, and complete a host of other complicated tasks.
For every task, there's someone who has done it before and knows how to do it right. But you can't simply get a group of specialists together and hope that they spontaneously organize themselves to build a skyscraper. You need a project manager, a foreman, or someone to who has a clear understanding of the grand scheme to manage the workforce. The project manager sets everything in motion, telling the specialists exactly what to do. In the world of object-oriented programming, your application is the project supervisor.
Each class has a specialized purpose. Fortunately when programming in Cocoa, Apple provides you with an army of specialists. The classes of Cocoa are experts -- master craftsmen -- at things like working with arrays, strings, and numbers. They know how to draw buttons, sliders, and windows. Together they have the know-how to run a successful application. Your job is to organize and manage these guys in whatever way you need them to work. And in this way, the task of building a complicated application -- a skyscraper -- is made that much easier.
Don't worry, they're good workers who will do what they're told. You just have to know how to communicate with them and understand how they operate. In other words, you need to understand how classes are built so you know what they're capable of accomplishing. In this column, I will go through the main concepts of object-oriented programming so you can be a more skilled manager of your army of specialists.