Object-oriented programming (OOP) is a programming method that combines data and instructions for processing that data into a self-sufficient “object,” or block of preassembled programming code, that can be used in other programs. Three concepts of OOP are encapsulation, inheritance, and polymorphism. Some examples of OOP languages are Smalltalk, C++, Turbo Pascal, and Hypertalk.
Imagine you are programming in a traditional third-generation language, such as BASIC, creating your coded instructions one line at a time. As you work on some segment of the program (such as how to compute overtime pay), you may think, “I will bet some other programmer has already written something like this. Wish I had it. It would save a lot of time.”
Fortunately, a kind of recycling technique now exists. This object-oriented programming. Let us explain this in four steps:
1. What OOP is: Object-oriented programming(OOP) is programming method that combines data with instructions for processing that data to make a self-sufficient “object” that can be used in other programs. The important thing here is the object.
2. What an “object” is: An object is a block of preassembled programming code that is a self-contained module. The module contains, or encapsulates, both a) a chunk of data and b) the processing instructions that may be called on to be performed on that data.
3. When an object’s data is to be processed sending the “message”: Once the object becomes part of a program, the processing instructions may or may not be activated. Activiation happens only when a message is sent. A message is an alert sent to the object that it is needed for an operation.
4. How the object’s data is processed-the “methods”: The message need only identify the operation. How it is actually to be performed is embedded within the processing instructions that are part of the object. These instructions about the operations to be performed on data within the object are called the methods.
Once you have written a block of program code (that computers overtime pay, for example), it can be reused in any number of programs. Thus, unlike with traditional programming, with OOP you don’t have to start from scratch each time.