In this article, I will show you how to decouple any system from the rest of your codebase. By doing this, your "decoupled" system will be fully testable and much easier to understand.

`Photo by freestocks on Unsplash

What does it mean for a system to be decoupled, and why is this a good thing?

For a system to e decoupled means that that system does not depend on any other system for it to perform its task. If this is true, no other system can change the behavior or state of the decoupled system. This makes it very testable, predictable, and easy to understand.

Sometimes it's OK to have two systems that are closely related to be tightly coupled, but when…

In this article, I will be showing you four simple steps you can use, to convert a state machine diagram into working code. These steps will make writing state machines so easy, that you will want to have all your stories described in state machine diagrams.

Photo by Yogesh Pedamkar on Unsplash

Before we get into the solution, let's understand what a state machine is. A state machine is a system that takes in events and produces new states given the accumulated events that it has received.

This diagram is a very common state machine that we find in most applications.

Writing a pure view model makes it very easy to test and understand. But writing a pure view model reactively makes for better code.

Photo by Steve Johnson on Unsplash

In my last article, we converted an impure view model into a pure one. At the end of the article, we saw that the mutability of one of the properties in the view model property is not ideal. In this article, I will fix this issue by converting this pure view model into a reactive one.

Let’s take a look at the view model again.

The name property in the view model is mutable, and…

Photo by Max Duzij on Unsplash

In my last article, I wrote about pure functions, what they are, and why they are awesome. This is the second part of a three-article series I am writing that goes into the concept of pure code.

In this article, I will be converting an impure viewModel into a pure one. I will show you how it's difficult to write unit tests for impure viewModels and how it becomes super easy once they are pure.

Below is a very common viewModel setup you might find in many codebases.

(Wondering what ImpureNameViewModelTypeis? Read this article)

Right off the bat, we…

Programmer: I write Pure functions now.
Mathematician: You mean functions?
Programmer: No, PUREEEE functions!
Mathematician: What the heck is a PUREEEE function?

Exactly, what the heck is a Pure function? And why is this mathematician confused?

Let me explain.

A very common answer you will get when asking developers “what is a Pure function?” is that a pure function only does one thing. But this is incorrect. A Pure function is described as the following;

In computer programming, a pure function is a function that has the following properties:
- Its return value is the same for the same arguments (no…

Model-View-viewmodel (MVVM) is one of the most used, and known patterns in mobile development. At its core, MVVM helps you separate your view logic from your business logic. The idea is that your views should not know where or how the data it is displaying came to be. In this article I want to show you how I write MVVM, and why I write it the way I do. I have seen many code bases that can be improved with what I am about to write. So let’s get into it.

When I am writing a pattern (or any code…

Terrick Mansur

iOS Engineer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store