A Design Pattern Story in Swift – Chapter 11: State
HouseOfFlower is hosting a betting sale. People can use a blue diamond to start a bet. If they win the bet, they’ll get one flower. The “FlowerHouseContext” is trying to keep a record of the business by using the four states: NoDiamond, HasDiamond, Sold, Soldout.
05 Jul 2015 Read more »A Design Pattern Story in Swift – Chapter 10: Composite
There is a MagicConference and all kinds of characters can participate by purchasing SinglePass or GroupPass.
05 Jul 2015 Read more »A Design Pattern Story in Swift – Chapter 9: Iterator(Sequence and Generator)
There is a restaurant with two kinds of menus: one for their VIP guests and one for customers who just want average fastfood. The two menus are in different format and one waitress has to be able to process both menus, in a simple way.
04 Jul 2015 Read more »A Design Pattern Story in Swift – Chapter 8: Template
There is very little difference between magic and art. It’s an act to create something from nothing.
04 Jul 2015 Read more »A Design Pattern Story in Swift – Chapter 7: Adaptor & Facade
We all have our innermost dream. Sometimes it becomes true, sometimes it doesn’t. When you see the tears in my eyes, that’s because my dream is broken. Fate often has its own play. We never know for sure.
04 Jul 2015 Read more »A Design Pattern Story in Swift – Chapter 6: Command
If you command wisely, you’ll be obeyed cheerfully. — Thomas Fuller
03 Jul 2015 Read more »A Design Pattern Story in Swift – Chapter 5: Singleton
Long before the seven kingdoms were created, there was a pen – a pen that can write stories into realities. In the vast universe, there is only one pen of this kind.
01 Jul 2015 Read more »A Design Pattern Story in Swift – Chapter 4: Factory
We all have our special weapons. And we fight for what we believed in.
01 Jul 2015 Read more »A Design Pattern Story in Swift – Chapter 3: Decorator
There is a powerful sorcerer in town. He sells magic potions and only charges them for blue diamonds. Blue diamond is a special kind of currency in the magic world and people are born with certain amount of that. The sorcerer would give old customers or his favorite customers different discounts.
30 Jun 2015 Read more »Strategy Design Pattern Updated Using Protocol Extension in Swift 2.0
I came across the Protocol-Oriented programming concept recently and I found it quite fascinating, so I decided to rewrite my previous story with protocols and value-based approaches.
29 Jun 2015 Read more »A Design Pattern Story in Swift – Chapter 2: Observer
In the deep forest, there is a beautiful witch who was born with the power to tell the past and future. In the beginning she was just a little girl in a nearby village. She knows everyone and whenever she sees danger in the future, she would warn the person. But soon she realized there are simply too many people to warn, and some of which don’t even want any help.
29 Jun 2015 Read more »A Design Pattern Story in Swift- Chapter 1: Strategy
Once upon a time, there was a girl living happily in the deep forrest. She did not know where she came, nor where she is suppose to be. The only unfamiliar memory she had is that many years ago, before she could wake up from the cold and molded stone, she heard a distance whisper, saying “home, home, this is your home”.
09 Jun 2015 Read more »