FormationLayout and Protocol-Oriented Programming in Swift

My favourite talk of WWDC 2015 was Protocol-Oriented Programming in Swift. However, when Dave Abrahams says, “Swift is the first Protocol-Oriented Programming language”, I didn’t get it. Isn’t protocol in Swift the same as interface in other languages? Isn’t “Protocol-Oriented Programming” the same as one of the SOLID principles - Dependency inversion principle - “Depend upon Abstractions. Do not depend upon concretions”? It is not new at all.

Then in the later part of the talk I learned from Dave how powerful protocol is in Swift 2, especially Self Requirement and Protocol Extensions, and why we should use protocols instead of classes for abstraction. I felt excited and already Protocol-Oriented myself after watching the talk. I need to do something to check if I really am :)

So here comes FormationLayout, a Protocol-Oriented AutoLayout library in Swift 2. Now I will show you how I made it Protocol-Oriented and why it is good.

Read More

BDD Demo with GameOfLife in Swift and Quick

BDD(Behavior Driven development) was firstly developed by Dan North as a response to the issues encountered teaching test-driven development:

  • Where to start in the process
  • What to test and what not to test
  • How much to test in one go
  • What to call the tests
  • How to understand why a test fails

That was version 1 of BDD in mid-2003. BDD v3 now is more about communications between all different roles in agile teams using the same language: GivenWhenThen([1] [2]).

I made some videos before to demonstrate TDD on Android platform using Conway’s Game of Life as an example. This time I will use this example again to demonstrate BDD on iOS platform in Swift and a BDD framework Quick.
(Code at GitHub)

1. Create Project and Add Quick Framework

Read More