What is a Monoid? Monoid is a property of a system which satisfies these three laws: Has identity Is composable and the order of composition doesnot matter: i.e. composition is associative The result of composing 2 such system produces similar system. i.e Closure property or endomorphism. Well, that sounds a bit abstract. Indeed. Well, is this any useful in programming? You bet it is. This post is entirely about understanding what a monoid is, with ideas we (OOP) programmers already know.Read More
Monadic Computation in Swift. Why?
I won’t go into the details of what a Monad is and what exactly it solves. What we will do here is try to come up with a monadic type to encapsulate network result. We will do a side by side comparison with the traditional/classical/imperative and the functional (monadic) approach. In the end you should be able to appreciate and hopefully use the monadic style of wrapping network result without being bothered about the nitty gritty details of what a monad is?Read More
When to refactor legacy code? Last few releases, I was working on a fairly old code. I was required to implement a small new feature in an item list controller. The controller maintains list of items in horizontal collection view. We were using this controller to show remote items and last seen items (local). Now the new feature was to use another API URL and then transform the received data into appropriate items.Read More
Precision Timing in iOS & Swift
Time is what we want most, but what we use worst. -William Pen Timestamp is a very important issue we deal with in every single iOS/OSX project. Unlike timestamp, sometimes we want to measure method performance. Practically, i would use it for fun exploration. However, there are cases especially in games development where the precise time helps maintain consistent gameplay with scores. I explored a bit on how we can leverage the systems provided APIs to just get the current time stamp as precisely as possible.Read More