As the software development caught more pace and found more applicability programs became more complex. The problem was, as the logic became more intense, managing programs became a real issue. Many software engineering techniques were invented and deployed but the issue was far from being solved. The most widely use modular programming which laid emphasis on functions rather than data itself couldn’t solve the problem. And then a new revolution was taking birth in the MIT labs(yes,those geeks again). The called it object oriented programming(OOP,i know it’s a weird name). Here they constructed a new approach to software development. They kept data at the heart of software development and built the programs around it. Lets understand some basic OOP concepts…

There are four basic OOP concepts(though there are more,but we’ll take them later).

  • Inheritance
  • Polymorphism
  • Data abstraction
  • Data encapsulation

Inheritance-

It is the process by which one object acquires the properties of another object.

This is important because it supports the concept of hierarchical classification.

As mentioned earlier, most knowledge is made manageable by hierarchical (that is, top-down) classifications.

If you describe the world in an objective way you must define everything according to its own set of stats I.e size ,weight etc. Animals for example also have certain behavioral aspects; they eat, breathe, and sleep. This description of attributes and behavior is the class (group) definition for animals. If you wanted to describe a more specific class of animals, such as mammals, they would have more specific attributes, such as type of teeth, and mammary glands. This is known as a subclass of animals, where animals are referred to as mammals’ superclass. Since mammals are simply more precisely specified animals, they inherit all of the attributes from animals. A deeply inherited subclass inherits all of the attributes from each of its ancestors in the class hierarchy. So inheritance in programming is analogous to familiar definition of inheritance.

Polymorphism

is a feature that allows one interface to be used for a general class of actions. The specific action is determined by the exact nature of the situation. Consider a stack (which is a last-in, first-out list). You might have a program that requires three types of stacks. One stack is used for integer values, one for floating-point values, and one for characters. The algorithm that implements each stack is the same, even though the data being stored differs. In a non– object-oriented language, you would be required to create three different sets of stack routines, with each set using different names. For example abs is a function that give absolute values. In java(OOP language) uses the same name for any kind of input data type but in C there are 5 or more abs functions for every input data type like fabs for floating-point number.

Ok I think its enough for this post next two we’ll take up in the next post

Advertisements