Design Patterns — I came across this term for the first time in my life in a job interview (mind you, I was almost two years into iOS Development then). I got back home and googled about them. It was embarrassing and interesting at the same time, as I found out that I had been using a few of those patterns without actually realising that I was doing so.
I forgot about that incident after several days and got back to my work. Fast forward two years, I was back at job searching and this time I decided to learn in depth about design patterns. As a seasoned iOS Developer, I was initially looking to learn the concepts through examples coded in Swift language.
Surprisingly, I could not find a single book or blog discussing design patterns in detail in the Swift language. There are tons of books and blogs discussing them in Java, C#, PHP, etc.
For someone who codes in Swift, it only takes a little effort to understand Java. So, I started learning the design patterns from different sources available on the Internet through Java examples. For practice, I started putting up a few examples in Swift for each of the design patterns.
Personally, cricket is something that I understand in and out. I can almost relate anything under the sun to a situation in cricket (okay, that’s a bit of an exaggeration).
So, I decided, instead of using different contexts for each of the design pattern examples, I would be using cricketing terms for all the examples I would be coding. I believe cricket is a very simple game, and even for those who do not follow the game, it should not be a big effort to relate to the cricketing terms.
That’s when I decided instead of just letting the code reside on my Mac, I would put a little more effort to take it to book form. That’s how this book was born!
Only recently I have open sourced all the code from my book on GITHUB. The reception from the community has been phenomenal and it was #2 on trending for the last week in Swift repositories.
I would suggest you code the examples (not copy-paste, but type each and every line of the code) in your Xcode playground and see the results for yourself. Then imagine a scenario where you would apply such a design pattern, and code an example for yourself.
I believe that’s how coding is learned.