If I can do everything with structural programming, why did you create object-oriented?

7

In the question about - All What can I do in POO I can do in PE? - the accepted and best voted answer says:

  

Yes, any programming language can do it all. Now, each paradigm has its way of organizing, so you can not always do it the same way. Moreover, with some languages and use of certain paradigms it is possible that specific tasks are easier to do in one paradigm than in another.

That is, it states that it is possible, and that any programming language can do everything, whether it be structural or object-oriented.

Thinking about this, I would like to know: if "any programming language can do everything,"

  • Why did you create object orientation?
  • Was it a need to increase the language / improve it? Or was it just to follow the "modinha"?

P.S .: More general views of languages, from my point of view can be answered, but I would like to know the specific PHP language.

    
asked by anonymous 23.06.2017 / 16:15

2 answers

9

To better organize complex tags, to better handle large domains. Yes, doing OOP in scripts , fleeting applications, simple, is not advantageous. But luckily many people do not do OOP in these things, although they say they do.

OOP is modinha if you consider that people use where they should not. Modinha is not something fleeting, it is something that is only being used because people use it without a clear reason. It is not modinha when used where it is useful. It is very modinha when the person talks about what he is doing and is not even there, she just wants to be part of the group that is" drowning ". And as I said in previous answer , it's teenage sex.

The creation of OOP does not have anything modinha. Most technologies are not modinhas. The same can not be said of several methodologies that were even created to meet a need, but do not fulfill the promise .

It's like carrying a gun, just to take an example. He is useful, but defending that everyone should be able to have a gun is modinha. It does not meet a real need.

In general PHP is modinha. You have a case that is not, but it is rare. And honestly when it is, it's usually the wrong language. PHP is more languages than script that exists, so how to name variable indicates this. Put OOP in PHP was and still is modinha. Of course the most precise definition of this is survival . Today few things need scripts , the bulk of development are on top of complex things. Without OOP the language would deplete a very small niche, which happened to Perl. But then the language was inconsistent.

OOP is much harder to understand and do right, so much so that everyone does it wrong. It's very common for people to complicate your design to try to be OOP without any advantage.

OOP is great in these cases of many relationships between objects, when objects are very complex, when there are subtype relations, hierarchies. GUI benefits a lot from this. Games usually benefit, some types of business. Frameworks and more complex libraries can benefit greatly.

OOP can be great for maintaining domains that tend to change a lot and are more about business rules than mechanisms, although mechanisms can benefit as well.

I reinforce that the answer says that OOP and PE are very different things. I would like everyone to read the links there to understand a little more about OOP (I know I did not answer fully) and understand that structured programming is something very simple and focuses on another aspect of OOP programming that does not focus . structured programming is not about code organization, it's about algorithm flow.

    
23.06.2017 / 16:32
2

Each type of programming paradigm serves a purpose, but as you said, structural can do the functions of an Object-Oriented, but when it comes to Objects only, OOP languages are much easier to work with and manage (most) memory in a better way for that purpose.

POO has concepts of inheritance, Abstract classes (Java) and encapsulation, which is the focus of this paradigm, which saves the programmer from many lines of code.

If we were to follow the logic that a single language is fundamental we would be programming in Assembly until today, or even in Binary, which does not seem very inviting, right?

So the answer to why other languages are created is simple: Each serves a purpose, but with natural evolution the language has been encompassing a greater content.

Worth reading Programming Paradigms and its differences

    
23.06.2017 / 16:29