Programming Patterns. Introduction
Here you can read all the information in written form:
About specifics of this tutorial
That can be not so obvious thing to answer, why do we need patterns at all, but I can give you multiple reasons why you have to use programming patterns. With programming patterns you can:
- Prevent reinvention of wheel;
- Increase speed of code writing;
- Make code readable for everybody;
Let’s go one by one and investigate each reason thoroughly.
Reinvention of wheel
The thing that want to avoid here is re-invention of patterns. So normally patterns resolve some typical tasks (e.g. single instance class, run-time type initialization etc.) and then you know how to implement this specific thing there’s no need to create it from scratch. And as you can understand then you don’t know how to implement patterns for typical tasks you’ll start from zero, and there’s no guarantee that it’ll be done efficient enough.
Speed of coding
This point is in a really close connection with previous one. Let’s say you know how to resolve typical tasks with patterns it means that time of writing for such code will be decreased. E.g. for example you found out that switching between algorithms in run-time is required and then you know Strategy pattern, you can just take and use it in place, and you can tell for sure, that this solution is an approved and tested one. So stability is onboard as well.
Readability of code
Normally on projects of any difficulty level other developers need to read code of each other. And then you see something that was fully invented by different person and lives its own live it can be a tricky thing to understand what’s actually going on here. It will be closer to translation from foreign language to your own. While the usage of patterns that both developers are familiar with can be kind of an international language, so you see common pattern and you already know, what problem is solved here and how it works (abstractions and structure inside, e.g. Factory pattern normally requires types that can be produced in the future).
(to Life, The Universe and Everything)
You need patterns mainly to use approaches that were created, approved and tested by other developers for you. Also then you used typical way to resolve some development problem it must’ve been understood by other developers correctly, what will save time in future for everybody.
Today we went through the basic reasons for patterns usage, I hope they’re clear enough and know you want to include programming patterns to your ‘necessary-to-study’ list. Next time we will start with exact patterns and you can see them in practice, all the code of patterns will be available on the Github for your usage and questions.
We are looking forward to meeting you on our website soshace.com