Swift Higher Order Functions

Here is what I like about Swift the most… it forces me to think in terms of what I can only describe as decoupled behavior. Behavior or implementation that doesn’t depend on any specific type. This can be clearly observed with higher order functions, protocol oriented programming or just Swift in general.

So what are they? Higher order functions are functions that take other functions as parameters. And even though the implementation of these functions can be, as any implementation, verbose and easily replicated, the advantage of using higher order functions is the fact that they promote a much succinct and easier to understand code by eliminating clutter. Some of these functions even have a default behavior (sort(_:) for example will sort elements in ascending order) which is very useful.

Continue reading “Swift Higher Order Functions”

Swift Higher Order Functions

Reusability With Swift Protocols

Aaaaaand I am back from the holidays… Christmas was great. I got a chance to spend time with my beautiful wife and two sons visiting “The German City” – Leavenworth. It was great to just chill for a bit… slay ride with kids was amazing. Seeing horses brought all my childhood memories back.

Anyway, I would like to kick off this year by spending a bit more time talking about Swift protocols. We’ve already covered it briefly here. Take a look if you are interested in what i cleverly titled as “Practical Protocol-Oriented Programming”. Even if you think you already know what protocols are, take a few minutes to read this article. There are some cool things I bet you didn’t know about.

Continue reading “Reusability With Swift Protocols”

Reusability With Swift Protocols