Society & Lifestyle
|Computing||Share This Page|
Oops… I did it Again!
|by Deepak Chandrasekaran|
This article is going to explain the object-oriented programming (commonly called OOPS) concepts used in languages like C++ and Java.
OOP's concepts have simplified programming like never before. Basically one can write programs in two ways:
One way is the process-oriented model, where the programs are written in steps of code. C language uses this approach, and as the programs become lengthy, the code gets more complex.
Other way is the object-oriented programming (OOP) way. OOP organizes a program around its data (also called objects) and a set of well-defined interfaces to that data. An object-oriented program can be called as a data controlling access to code.
Abstraction is an essential element for this, which manages the complexity. In a sense, when someone works on a computer, not necessary that he should know the working of each and every part of the computer. Even without the hardware knowledge, he can e-mail, type or do other jobs on the computer. Thus people do not think of a computer as a unit made up of hundreds of cards and chips, but as a well-defined object with its own unique behavior. This is the advantage of abstraction.
Object-oriented programming is modeled on how, in the real world, objects are often made up of many kinds of smaller objects. This capability of combining objects, however, is only one very general aspect of object-oriented programming.
The Three Oops Concepts:
Since the purpose of a class is to encapsulate complexity, there are mechanisms for hiding the complexity of the implementation inside the class. Each method or variable in a class may be marked public or private. The private methods and data can only be accessed by the code, that is a member of the class. The public method has all details essential for external users.
On the lighter side, extending this analogy to a dog, its sense of smell is polymorphic. If the dog smells a cat, it will bark and run around it. If the dog smells its food, it will salivate and run to its bowl. Note that the same sense of smell is at work in both the cases. The difference is what is being smelled, that is, the type of data being operated upon by the dog's nose!
|More by : Deepak Chandrasekaran|
|Views: 2116 Comments: 0|
|Top | Computing|