Object Oriented programming

 Much has been made of the concept of object-oriented programming. Some have claimed that it is the panacea for all software development ills; others claim that it is mostly hype. The truth probably lies somewhere in the middle. Effective o-o programming is different from conventional programming with languages such as Pascal, C, and Basic. One difference comes from thinking of a program as a hierarchy of classes and methods. From this perspective comes the strategy of developing a program in terms of multiple levels of "tools." Instead of writing long blocks of code to accomplish a task, a programmer builds several high-level tools that can be put together, often in just a few lines of code, to accomplish the task. The programmer then builds several lower level tools to implement each of the higher level tools. Etc. The process continues until the lowest level tools can be built in just a few statements.

Of course, one does not have to follow a top-down strategy. The process can proceed bottom up, beginning with the programmer developing a set of low level tools, combining them to implement a higher level set, etc., until reaching the top. This practice is often followed in a distributed way with specialized developers building general libraries, or packages as they are known in the Java world, that are distributed as basic building blocks to the general programming population.

Learning to program in an object-oriented way is not something you can just sit down and do or can memorize. It takes time. It is a way of thinking. But, if you persist, you will at some point it will just happen. You will wake up some day and realize that you are thinking about your programming in a different way. In the meantime, you can encourage that process by learning the basic concepts of o-o design and considering how you can use them in your program designs. And practice, practice, practice writing code. It also helps to study other people's code critically, noting constructs that are simple, powerful, and elegant versus those that are long, messy hacks.

Thinking in terms of a hierarchy of classes is important for o-o programming, but it is not the whole picture. There are some eight or ten basic concepts that must be understood. In the discussion that follows, key concepts are introduced. As you will note, there is a high degree of circularity among them, in which one concept is best understood in terms of another. I don't know any way to avoid this. The remedy, I suggest, is to read the chapter through at least twice. By the second reading, you will have encountered the "down-stream" concepts useful or required to understand earlier ones.



Concepts

The discussion that follows is organized in terms of key concepts associated with object-oriented programming. Each term or concept will be introduced and explained, usually with respect to other terms or concepts that have already been discussed or will be shortly.

Class

 

 Variables/Attributes

 Methods

 Inheritance

 Instantiation

Object

Messages

 
 

Additional Reading

If you would like to learn more about