Why are OOP patterns needed?

    This article is an attempt to answer the question of the 11-year-old Olympiad: “Why do we need patterns?” I haven’t sent it yet, I put it up for general trial and ask for any criticism. The goal is not to give an exhaustive answer, but to raise new questions.

    so


    How to teach programming at school? They give you molds and learn how to make cakes from sand. This is good, because you have to start somewhere.

    But you want to do more serious business. For example, build a house. Of what? You were taught only from sand. They did not tell you anything about bricks - this is not the school's business. (I'll tell you a secret: they don’t know how.)

    Do you want to build a house? Wait, let's learn how to burn bricks. Or let's go buy in the market. Bricks are patterns.



    Why is it important? It’s just that many of my friends (precisely from the category of “olympiadniks”) were cruelly disappointed in programming, because they wanted to build sand castles. Outwardly, it was cool! For example, my friend wrote a very complicated logic game, but “on the knee”, on anti-patterns, as we were taught at school ...

    An “anti-pattern” is how programs should not be designed.

    And we also made cars with him on electric motors. My cars always drove faster, but I did them “on my knees”, from improvised materials with electrical tape. And he always tried to apply some design methods, standardized “production processes" ... His machines were slower. But guess: which of us has now become a designer (designs gearboxes)?

    Here is what I am observing: if you now learn to build houses from sand (beautiful!), Cars on scotch tape (fast!), Then it’s almost impossible to relearn. There will be no motivation.

    Conclusion: if you want to become a professional, it is better to start building a house of two bricks than a huge sand castle. Although the castle is easier.



    When you begin to slowly apply OOP techniques in your projects (even in the simplest ones), you will immediately see that the patterns prevent you from stepping on the same rake. Then you will see how they simplify the interaction between developers. And generally make life easier.

    The application of patterns is the knowledge that comes only with experience. If you already start trying to apply them, you will save a few years.

    PS Habru:


    The question “Why do we need patterns ... for an 11-year-old ?!” I suggest not discussing it. About 15 years ago I would have been told at least something from the design! (With all due respect to the approach “let him cones, and then we will tell him that there are patterns” ...)

    By the way, the trend of “OOP from the cradle” is not new .

    Related discussions

    Why design
    patterns are needed OOP patterns in metaphors
    How two programmers baked bread

    Also popular now: