Join our blog to meet new people, write your own articles, publish event announcements and announcements, and participate in the discussion of publications. We have created a single space for communication between computer technology market specialists and everyone who is interested in modern technologies.
Code
Object-oriented programming

Most of the novice programmers are looking for “How to program in Java (C ++, etc.)” on the Internet. And they immediately begin to study the syntax of this or that programming language. Even in programming courses, they started straight away with syntax. People think they have already learned the language, but when it comes to big projects or creating their own program, many beginners find themselves at a dead end. Because they don’t know where to start and how to think in OOP.

Important information about OOP:

  • be able to design (represent) code in the form of objects;
  • know what inheritance, polymorphism and encapsulation are
  • know the difference between procedural and OO programming.

Designing code as objects

This is a very simple thing that is very difficult to understand the first time. For example, a bicycle is an object.
It has a steering wheel, two wheels, pedals, a seat and other parts. Each part has its own property (the steering wheel steers, the pedals drive the bike). The same thing looks like this in OOP:

  • Classes and subclasses (bike, its parts, color, etc.)
  • Methods (properties of the steering wheel, pedals, etc.)

Inheritance, polymorphism and encapsulation

Inheritance is like in life, but in classes. If one of the classes inherits from another, then it knows everything that its ancestor (inherited class) knows. The plus is that if you have many types of TVs, you can write one main class that has the properties (methods) that all types of TVs have. And inherit all TVs from the main class. After that, you will simply add special properties or definitions for each TV. This process is called polymorphism.

Encapsulation is needed to avoid bugs. For example, if in the field where you need to enter the name, we randomly entered a number or sign. The encapsulated program will immediately throw an error. We do not need to provide for the input of numbers or other characters as in procedural programming.

Difference between procedural programming and OOP

The difference is that OOP is much more readable and organized. But in procedural programming, it’s easy to write short programs, or solve problems. Today, almost any company requires knowledge of OOP, no matter what language they program in.

Leave a Reply

Your email address will not be published. Required fields are marked *