When to switch from procedural to OOP?

In most OOP discussions, he said that the advantage is reuse. You ask for additional work to define your classes, and this saves you time later when you can create many instances and extensions of these objects.

This seems to mean that you should not switch from procedural to OOP programming until the trade-off between writing everything to objects is equivalent to the time you save.

In general, when is the time to switch from procedural to OOP programming? Are there any signs / characteristics that you usually look for to know that your project should make this switch?

+3
source share
7 answers

I guess this question from a point of view / paradigm is to be a beginner. As soon as a programmer has experience writing object-oriented code, you can, of course, use this architecture from the very beginning. In fact, I would say that a top-down approach can save you a tremendous amount of time on large projects.

For the bottom-up scenario that you draw, I would say that you have to feel it. Link this wikipedia article for more information on different approaches, generally speaking.

Specifically for PHP, I would say that you can use this approach for migration:

  • , (..: ) .
  • . , static (singleton) .
  • / , .

- OO, . : - OO , ( ) .

+4

, . , , OOly, , .

+3

, . , OOP, - GUI .

, - OOP, , , .

+1

. , , , , . .

, . , () . , , , .

+1

, . - - .

OOP - , , . . .

, , . , , .

0

, , , :

  • , ? ? ? ?

  • , , , ? , ?

If you prefer 1, go to OOP, otherwise if it looks more like 2, then go to the procedure.

If in doubt, use whatever is convenient for you.

0
source

It is very rare to change the programming style of the current project.

You can always apply OO principles to procedural code if you want to get clearer answers between your objects.

check for example this very interesting book on coding OO in ANSI-C

0
source

Source: https://habr.com/ru/post/1780104/


All Articles