Fundamental Concepts of Object Orientation

Fundamental Concepts of Object Orientation

Fundamental Concepts of Object-Orientation

Objects

  • The central idea of Object-Oriented Programming (OOP) revolves around objects.
  • An object is an entity that has state, behaviour and identity.
  • The state of an object is stored in fields (variables), while behaviour is defined via methods (functions).
  • The identity of an object is what makes each object distinct from each other, even if their state and behaviour are identical.

Class

  • A class is a template or blueprint for creating objects.
  • It defines what properties an object should have and what actions it can perform.
  • Every object is an instance of some class.

Encapsulation

  • Encapsulation is the wrapping up of data (fields) and methods into a single unit known as class.
  • One of the key principles of OOP, it provides ‘data hiding’; you can hide details about an object’s internal state and protect it from other parts of the program that might change it.

Inheritance

  • Inheritance is the process by which one class acquires the properties and methods of another class.
  • An existing class is known as the parent class, and the class that inherits from the parent class is the child class.
  • This allows for efficient reuse of code and simplifies the programming model.

Polymorphism

  • Polymorphism is the ability of an object to behave in multiple ways.
  • This means that a single variable can be used to reference objects of different classes, and automatically call the method that is specific to the type of object the variable references.
  • Useful for allowing objects with different internal structures (i.e., different classes) to share the same way of performing certain tasks.

Abstraction

  • Abstraction is the process of hiding the working style of an object, and only showing the functionality to the users.
  • In other words, it displays only essential features of an object and keeps the complexity hidden.
  • This can simplify programming by reducing the dependencies between different parts of the code.

For effective programming, mastering these fundamental Object-Oriented concepts is paramount. They form the core of Object-Oriented Development and using them properly can improve the structure and efficiency of your code.