Object Oriented Programming principles

Relevant categories: Software Architecture

In Object Oriented Programming we use objects and their relationships to develop an application. OOP mainly came to use in 1990s. OOP is a very strong methodology. Every programming language will have to support a minimum set of principles in order to be called an OOP language. There are 4 main features that every OOP language or application should support:

  1. Encapsulation: it means hiding the details of the implementation of a component from other parts of the system. This process can be achieved by using methods. Methods provide information about the state of the component without getting involved in the details. Blocks of data and behavior pattern are encapsulated into entities called classes. Each class contains methods, constructors and attributes. Through the use of a class we can use its functionality without knowing the details of how it works.
  2. Abstraction: abstraction and encapsulation are two closely related concepts. Abstraction is extracting a virtual view of concern from the real objects that are similar to the real world object as far as the application is concerned. We use abstraction to make the development of big projects easier. In fact, abstraction is a way for solving complexity by breaking one big project to smaller parts.
  3. Inheritance: We can create new classes by extending existing classes. Inheritance is used to model the “Is-A” relationship between two entities. When we create inherited classes, the data and functionality of the base class is added to the derived class, and then new features and behavior is added.
  4. Polymorphism: It is implemented by having multiple methods with the same name but different implementation and functionality. There are two types of polymorphism. The first one is overriding or run-time polymorphism which according to the dynamic object at run time chooses which method to use. The second one is overloading or compile-time polymorphism, where the compiler chooses which method to execute during processing the code.


Links: