DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 968,873 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
liasu Tolulope
liasu Tolulope

Posted on

INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

Object-oriented programming (OOP) is a programming paradigm that is based on the concept of objects, these objects contain data which can also be known as properties, and code which can be referred to as methods. It focuses on the objects that programmers want to manipulate rather than the logic that is needed to manipulate them.
One cannot discuss OOP without mentioning classes, classes are abstract reusable, and simple pieces of code blueprint that are used to create objects. Functions can be contained in classes and applied to objects of the same type with the class. An example to further explain classes would be lets say I own a cat I can list all the properties a cat can have in my class for example color, eye color, name and then with this class I can create objects myCat, friendscat, neighborCat and many others. I can also create a class with a function bathCat that can be applied to all other cats(other objects of the same type).

      ** Pillars of object oriented programming**
Enter fullscreen mode Exit fullscreen mode

There are 4 pillars of object oriented programming namely;

  1. Inheritance: this is a pillar of OOP that allows code from a class to be reused by other classes. There is also a definition of relationships between classes that leads to there being parent and child classes where child classes are created by extending the functionality of the parent classes and can have their own additional properties/ attributes.
  2. Encapsulation: this is a principle that ensures the security of programs and prevents the corruption of data through the ability to select information that will be revealed from all the information contained in an object. The class template stores the code that defines attributes and behaviors. When an object is then created from the class the data and methods are encapsulated in the object.
  3. ** Abstraction**: this is an extension of encapsulation in which simplicity is achieved by only displaying information that is relevant for the use of other objects and hiding away unnecessary implementation code. It uses simple classes to represent complex things and hides away complex details from users
  4. Polymorphism: in this pillar objects are designed to share behaviors. Specific child behaviors can override parent behaviors using inheritance. Through polymorphism a method can execute different behaviors through either method overriding where a child class can have a different implementation than its parent class or method overloading where methods have the same name but different method parameters are passed into the method call creating different results

Advantages of object oriented programming
Object oriented programming is one of the most popular programming paradigms and is referred to as a standard way to code some of the many advantages of using it are:

  • It is easily upgradeable and scalable
  • Reusability which causes an increase in productivity
  • It is secure and protects information through encapsulation
  • It is easier to debug
  • Allows class-specific behavior using polymorphism Some of the most common object oriented programming languages include, java, C++, javascript, and python.

Top comments (0)

🌚 Life is too short to browse without dark mode