Website uses cookies. Cookies remember your actions and preferences for a better online experience. We don`t share information with third parties without your knowledge.
Object Oriented Programming (OOP) is one of the programming approaches, also known as paradigms (we wrote about them in a previous BizUPLab blog post). OOP is based on the use of objects and classes. It is based on four main elements: classes, objects, attributes and methods.

To understand the essence of OOP, compare it with other paradigms, such as procedural programming. It does not work with objects, but with functions. Writing a function is easier than writing objects and creating relationships between them. But if you have to write a large and complex program, you end up with a huge block of code with many different functions. For small changes you often have to redo almost the whole program. When using OOP, it is sufficient to modify only the part of the code that needs improvement.

Object-oriented programming. Principles

Structure
The concept of OOP includes not only the storage of data in memory, but also the code responsible for working with it, explained the developers of the IT company BizUPLab. They are combined into a single container - an object. Variables stored inside the object are attributes, and functions are methods.
  • Object - a code fragment that describes an element with defined attributes and methods. An object is an instance of a class. For example, a game may have a character class and its instances will be specific heroes.
  • Attributes are properties of an object. For example, a character in a game might have health, agility, strength, etc.
  • Methods are functions within an object or class that define the behaviour of a particular object. For example, a character in the game can run, jump, use a weapon, etc. When a character performs an action in the game, it calls a method described in its object.
  • A class is a template from which objects can be created. Classes can inherit characteristics from each other. For example, a game has a general character class and its subclasses. A subclass inherits the properties of the parent class and can have its own properties.
The principles of object-oriented programming
OOP has three basic principles:
  • Inheritance
  • Encapsulation
  • Polymorphism

Inheritance can be compared to cloning. This principle is the essence of the relationship between classes and objects. It means that each child "clone" inherits the attributes and methods given in the parent element: it can take all of them, drop some, or add new ones. In this case, you do not need to specify the same data many times.

Encapsulation. This is where you store the data needed to make the object work. Foreign objects and classes cannot modify it. Only public attributes and methods are available to them. This principle protects the data of an object or class from damage by outsiders.

Polymorphism is a redefinition of behaviour. The same method can work in different ways. For example, the parent class "person" can move, the child objects "driver" and "pedestrian" can do the same, but in different ways: one in a car, the other on foot.

Advantages and disadvantages of OOP
The advantages of object-oriented programming are:
  • It is more convenient to write code with objects. Easier to write code with classes or methods. In addition, it can be easily transferred to other projects.
  • Code is much easier to read, even by someone else.
  • Easy to update. Just change a class or method in one place, and everything in the inherited element changes.
  • Good scalability. Thanks to the independent modular architecture, different developers are responsible for different modules of the program.

The disadvantages, according to BizUPLab Budapest experts, are:
  • Difficult to learn.
  • The worst performance. Objects consume more memory than programs without OOP. This also applies to the compilation speed.
  • The amount of code is higher than in procedural programming. This is a plus when the structure of large programs becomes clear, but for small software products it is a waste of time.
We help business people manage their resources efficiently and systematically achieve success.
1114 Budapest, Bartók Béla út 66. 3. em. 4.

info@bizuplab.com
Contact Info
Copyright © BizUPLab, 2023 - 2024