V
V
v- death2015-08-05 02:09:23
PHP
v- death, 2015-08-05 02:09:23

Should you use oop?

Good afternoon. I walked around the Internet and everywhere they write that OOP should be used wherever possible (as for me, it’s more difficult to understand OOP noodles than functional ones)
And I came across two decent sources. The first is VK (they don't use OOP and say it's slow) and the second source is phpclub.ru where the article said that PHP was not originally conceived as an object-oriented language and therefore it's better to write in a functional style. Split all functions according to their intended purpose and write them to different files. Thus, build an API for your application. For example, the
UserCreate , UserAuth, UserBaned functions should be in the user.php file, and the ChatNewRoom, ChatNewMessage, ChatDeleteMessage functions in the chat.php file
As for me, the second option is beautiful or something. But how will it be right if I work on a project alone?
phpclub.ru/detail/article/phpmistake_2#11
PS I'm sort of getting
into OOP. And I wrote a couple of robots on it, I didn’t notice a strong difference in speed between OOP and non-OOP projects.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
index0h, 2015-08-05
@vGrabko99

What is easier without oops is definitely overkill for a 100 line script.
The rest is definitely necessary .
OOP gives you the concept of "data entities", at a minimum. You can certainly cover yourself with arrays, but in this case it is better not to use the word "security" in the lexicon.
OOP provides a separation of duties. Of course, you can pile up 1kk of functions and bungled vermicelli based on them, when you pour a couple of buckets of blood from your eyes - remember my words.
OOP gives code interchangeability by interface (Polymorphism), as a result - the ability to vary the logic, without a million switch-cases and complex conditions.
OOP gives data concealment (Encapsulation). If a variable can be changed anywhere in the project (global for example) - it will be changed somewhere, you may not know about it (or simply forget), as a result, your code will work unpredictably.
OOP makes it possible to expand the functionality of generated entities (Inheritance), as a result - DRY.
What Vitaly Pukhov wrote is not true. Easy !== correct, convenient, human-readable, testable, reliable. It's usually easy to write shit. The phrase "works the same" usually means: "yes, I understand that it's bad, but I can't do better."
You are not looking there. Performance in a stateless language ... In general, look at the compiled ones))
* You correctly said about vk, but you forgot 2 important nuances: it was written when there was not much OOP in php; they have their own KPHP))
* For comparison, facebook also has its own php: hhvm, but it is very objective.

V
Vitaly, 2015-08-05
@vt4a2h

Learn Russian first. PHP is too early for you.

H
heartdevil, 2015-08-05
@heartdevil

I advise you to move to OOP as soon as possible and do everything in OOP.
If earlier it was the case that everyone wrote functions, and OOP was the exception, now everything must be done in OOP and only in exceptional situations, functions.
And why I advise you, because OOP is not so easy to understand. There are a lot of subtleties. Therefore, the earlier you start, the more experience you will gain when you work on serious projects. If you are not a genius, then it will take you more than one year to master it sufficiently (depending, of course, on the intensity of work).
You don't need to look for the inapplicability of OOP to satisfy yourself that you don't use OOP. In our reality, this is nonsense. Only OOP.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question