U
U
Umid Rifkatov2020-04-27 14:49:23
Python
Umid Rifkatov, 2020-04-27 14:49:23

How does OOP really help in a real program?

I am writing a telegram bot, the code has become very cumbersome and unreadable. I decided to apply OOP since. in the pros of OOP it is written that it simplifies code support and its readability. I read all the courses, reviewed the Corey Schafer video and I can’t understand how all this can help me write more concise code so that it can be maintained, easily modified and remain DRY. Thanks for the answer.

Answer the question

In order to leave comments, you need to log in

5 answer(s)
M
mayton2019, 2020-04-27
@Umidrifkatov

OOP is cleaner development using the principles of SOLID, KILL, YAGNI (these are abbreviations) and if you are a 1 developer it will be very difficult for you to discipline yourself to follow OOP. In terms of meaning, it looks like a very strong formalization of logic so that there is not 1 long sheet of code, but there are small entities of 5-7 lines each and each of them would have 1 single area of ​​responsibility.
By and large, the benefits of OOP are manifested in very large projects (more than tens of thousands of lines of code) and where many developers are coding and making changes at the same time.
If the author has a small pet-project, then perhaps he does not need OOP.

M
Maxim Fedorov, 2020-04-27
@Maksclub

OOP simplifies code, logic and understanding...
But only in the case of a trained person. Accordingly, while there is no awareness of what is happening and experience, then the stump is clear - it will be difficult and
incomprehensible . Krch all arguments work for situations when programmers are already programmers, and do not want to be them . How OOP can help: Delineate your abstractions explicitly with a name, state, and behavior, as well as a description in code. It will allow you to add new types easily and always control this or that context in the form of a meaningful unit, and not 100,500 factors, and even under some other conditions.

Without OOP, abstractions will not have clear boundaries and the meaning will be assembled in a disassembled state from grains of code and data, but such a procedural approach also has advantages.

A
Adamos, 2020-04-27
@Adamos

OOP will allow you to keep in mind only the necessary piece of code that you are currently working on. Because its relationships with other pieces of code are neatly built, clear and minimal.
Naturally, in order to achieve this, you need not read courses and watch cartoons, but write, throw out what you have written and gradually learn how to write so that you don’t have to throw it away.

S
Sergey Gornostaev, 2020-04-27
@sergey-gornostaev

Re-read all the courses reviewed the video

It's strange that it didn't work!

00013r4b.png

V
Victor Bomberow, 2020-04-27
@majstar_Zubr

OOP is not about laconic code, but about simplifying changes, because all areas of change in text form are localized in classes, namespaces, modules. Areas of change are directly related to abstractions, and the better the abstractions are formed, the faster and easier it is to refactor the code. In the general case, abstractions are understood not only as models and entities that relate to the task, but also as processes associated with them,

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question