Object Oriented Programming

Object Oriented Programming is a programming paradigm in which we work around the objects.

In OOP, we create objects and objects have
  • Attributes/Properties/Fields
  • Behaviours
which are defined inside the class.

Object is the instance of class.
Class is a template which contains attributes and behaviours of objects.

For example, we have class named animals. The objects will be lion, monkey, zebra etc. objects have attributes, lion is brave. and behavior, monkey can jump. These behaviours and attributes are defined inside the class.


Class

Animals

Properties (data members):

brave, intelligent, beautiful

Behaviors (member functions):

walk(), eat(), sleep()

Objects

Lion

Elephant

Donkey

Zebra



A simple explanation:
An object created as an instance of a class will have all the properties and behaviors of that class. For example, if the animal class has properties like brave, intelligent, magnificiant. And we create two objects lion and donkey. Then lion and donkey both will inherit all the properties. If lion is magnificiant, the donkey will also be magnificiant if it is the instance of the same class.

Why OOP:
  • It makes your code easier to read.
  • Makes the code 'DRY' - Do not Repeat Yourself.
  • Easier to find errors
  • Code looks beautiful and structured.
  • Code will be reusable.
  • Less time consumption.

Here is a roadmap to OOP:

1. Classes and Objects:
Learn about concept of classes and objects and how they interact.

2. Four pillars of OOP:
Study the four pillars of OOP.
  • Encapsulation
  • Inheritance
  • Polymorphism
  • Abstraction
3. Class Relationships:
Study different types of class relationships, such as aggregation, association, and composition.

4. Study Design Patterns:
Study about the different design patterns.

5. Error Handling and Debugging:
Learn how to handle exceptions in OOP.

6. Software Development Principles:
Learn about software development principles.

Now move to advanced concepts of Object Oriented Programming and start developing softwares.