This article is an attempt to answer the question of an 11-year-old Olympiad: “Why do we need patterns?” I haven’t sent it yet, I take it to the general court and ask for any criticism. The goal is not to give a comprehensive answer, but to raise new questions.
so
How to teach programming in school? You are given molds and are taught to make sand cakes. This is good, we must begin with something.
But you want to do more serious work. For example, build a house. Of what? You were taught only from sand. You were not told anything about bricks - this is not the business of the school. (I will say in secret: they do not 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? Simply, many of my friends (precisely from the category of “Olympiad”) were severely disappointed in programming, because they wanted to build sand pits. Outwardly, it was cool! For example, my friend wrote the hardest logical game, but “on the knee”, on anti-patterns, as we were taught in school ...
“Anti-pattern” is how not to design programs.
And we also made cars with electric motors. My cars always drove faster, but I made them "on the knee", from scrap materials with electrical tape. And he always tried to apply some design methods, standardized "production processes" ... His machines were slower. But guess: who among us has now become a designer (designs gear boxes)?
This is what I observe: if you now learn to build a house out of sand (beautiful!), Cars on scotch (fast!), Then it is almost impossible to retrain. Motivation will not be.
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 lock is easier.
When you begin to slowly use the techniques of OOP in your projects (even in the simplest ones), you will immediately see that the patterns do not allow you to step on the same rake. Then you will see how they simplify the interaction between developers. And generally make life easier.
Applying patterns is knowledge that comes only with experience. If you already start trying to use them, you will save a few years.
PS Habra:
The question "Why do we need patterns ... 11-year-old ?!" I propose not to discuss. I would have told about 15 years ago at least something from the design! (With all due respect to the approach, "let them bump cones, and then we will tell him that there are patterns" ...)
By the way, the trend "OOP from the cradle" is
not new .
Related Discussions
What are the design patterns for?
OOP patterns in metaphors
How two programmers baked bread