Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Object Oriented Programming (OOP)

Object oriented programming is a paradigm used in software engineering that revolves around “objects” which contain fields (attributes) that describe it and procedures (methods) that allows interaction with it. OOP languages are diverse, but the most popular ones are class-based, meaning that objects are instances of classes, which also determine their types.

OOP basic principles

Inheritance

The inheritance principle states that objects can inherit from other objects creating a parent-child relationship. A child object has access to all the fields/characteristics and procedures from the parent.

Polymorphism

The polymorphism principle states that a child object can either overload or override any of the inherited procedures from the parent. This way each child can define its own behaviour when executing an inherited part of code.

Abstraction

The [abstraction] principle states that you can define the way how an object should look but not how it should behave. Using abstraction we can define particular what an object should do but not providing the details of how it will do it.

Encapsulation

The encapsulation principle states that the object should be the owner of how it changes it’s fields/characteristics by making private the procedures/methods that directly manipulate them. Public procedures/methods are created that allow interacting with the object itself and eventually may change state of the object, but in a controlled manner.

Examples