How To Refactor Elm Application Using Type Aliases — Tentamen Software Testing Blog

Image by Steve Buissinne from Pixabay

TL;DR

In the previous post, we explored the Elm architecture life cycle by pressing our heart like button. It is time to handle our accumulated technical debt by refactoring the Picshare application using Type Aliases. This post is part of the functional language series, and it is based on a remarkable book, Programming Elm Build Safe and Maintainable Front-End Applications by Jeremy Fairbank.

Why Refactor

By refactoring our application, we are handling accumulated technical debt of not maintainable code. We first make a feature to work. Then we refactor so we could add additional features by not breaking the current feature set.

Type Alias

You use Type Alias when you have in your codebase the same type annotation in several places. In our case, this is our record model:

Alias Constructor

With alias constructor, you could use type Alias to record type with values:

Remember

Refactor is an important skill in every programming language.

Founder of Tentamen, software testing agency.