Z
Z
Zrq122016-10-24 22:14:59
PHP
Zrq12, 2016-10-24 22:14:59

Do I need to learn OOP (PHP)?

I don’t want to offend anyone and make a mess .
Goodbye OOP , I recently started learning PHP, tightened up the basics, got to OOP, but the article scares me, so is it necessary to learn OOP or functional programming: Welcome?

Answer the question

In order to leave comments, you need to log in

9 answer(s)
T
T_y_l_e_r, 2016-10-24
@Zrq12

You must Fedya, you must...

S
Sergey, 2016-10-24
Protko @Fesor

but the article scares me, so is it necessary to learn OOP or functional programming: Welcome?

You don't need to learn OOP. Most seem to teach but it turns out badly. OOP needs to be understood. And it is rather design than programming.
It’s worth starting with structured programming in principle (OOP is just a development of these ideas), to figure out why global variables are still bad, because it’s much easier to live when you don’t need to take into account time during development. About how to do decomposition using functional abstractions, structure the code. The concept of connectivity, dependency management. You can read Dijkstra's message to the people . Still, you need to understand where the legs of the whole hype grow from and not write articles after understanding the issue only partially.
And so ... let's just say, you have to use classes. In PHP, there is no other way to isolate state. You just don't have to think that OOP is about inheritance (which is what most of the article is about), it's about state isolation, the interaction of objects / modules through "communication" (tell don't ask, the law of demeter), about late binding (the ability to replace the implementation) .. And not as not about classes. Classes are just a way. Encapsulation, polymorphism, inheritance - all this was before OOP. Unless inheritance in Simula67 was made in a more convenient form. But still, this language should not be considered object-oriented. On its basis, then Stroustup made pluses, and also did not think to make an object-oriented language. He wanted to structure procedural C, to set the development culture, so to speak. He didn't want to change the paradigm.
Basically, the problem today is that people understand OOP only as classes, patterns, and that's it. And why it was invented and how it differs (if it differs) from the good old procedural one - this is no longer vkurse.

O
Oleg, 2016-10-24
@politon

If you are a g ... nocoder, then it is unnecessary))

O
OnYourLips, 2016-10-24
@OnYourLips

The article is a mediocre stuffing.
The first comment of 2 sentences refutes it.
And you will have an adequate opinion only after 5+ years of experience.

R
Rou1997, 2016-10-24
@Rou1997

In order to avoid "srach", you need to decide on the goal and go towards it, choose all the tools based on it, if this is not done, then without "srach" in any way, it's checked.

P
Puma Thailand, 2016-10-25
@opium

So all code in php oops or procedural

V
Vitaly Vitrenko, 2016-10-25
@Vestail

IMHO for me oop is what makes programming really interesting.
Programming in procedural style is boring :)

A
Anton Tikhomirov, 2016-11-03
@Acuna

The article is not a weak stuffing to support activity on your blog, as Mail.ru likes to do when there is nothing sensible to write, but it is necessary.
It is necessary to learn, if only because it is convenient. Let me give you a good example: you have a method for connecting to something (to some database, FTP, it doesn't matter). It's called query(). You can define a class with this method when you start your project (for example, in index.php). For example, like this:

$db = new DB ([
  'server' => '127.0.0.1',
  'user' => 'root',
  'password' => '',
  'database' => 'my_db',
]);

As you can see, this class is initialized with the desired settings. When creating it in the __construct () method, you can initialize the connection to the database itself, the selection of the required database, etc. And already in other methods you can use this variable ($db), introducing it into any method using the global operator. For example, $db->query() queries the database (remember that we already initialized the database connection when we created the class to work with it, so we can query it from anywhere in your script). I'm not talking about the fact that methods can have the same names in different classes, but you will always know which instance this method is from and what it does.

A
Arseniy Sokolov, 2016-12-15
@ArsenBespalov

The issue was resolved, the hostname is still server.mycompany.ru , I just added the following options:

MASQUERADE_AS(`mycompany.ru')dnl
FEATURE(masquerade_envelope)dnl
FEATURE(masquerade_entire_domain)dnl
MASQUERADE_DOMAIN(mycompany.ru)dnl

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question