Beginning with the Right Datatypes
An introduction to the techniques to choose the appropriate data types in Elixir.
We'll cover the following
Introduction to datatypes
The data layer houses the simple data structures our functions will use. Just as an artist needs to learn to mix paint colors on their palette, Elixir developers need to know the best ways to mix data structures. Every programmer making a transition to functional programming needs to understand its impact on data design.
In this course, we won’t go over what maps or lists are, but we will provide an overview of what kinds of data types to choose for selected tasks and how we can weave them together into functional data strategies. We’ll cover some dos and don’ts for the most common data types and learn some tips for choosing good ways to express the concepts in our program.
Datatypes used in the counter
Our counter’s datatype couldn’t be simpler. It’s an integer. Normally, we’d spend much more time thinking about our data than we do here, and sometimes begin to code up the significant entities in our system. We don’t need to do that for our counter, though, because Elixir already has the integer and supports the things we’ll do to it.
Motivation
As this course progresses, we’ll spend a reasonable amount of time working through data structures. Our focus will be primarily on three areas:
-
We’ll look at what’s idiomatic and efficient in Elixir.
-
We’ll review how our structures will influence the designs of our functions.
-
We’ll consider some of the trade-offs around cohesion, or how closely we group related bits of data.
When the data structure is correct, the functions holding algorithms can almost seem to write themselves. Get them wrong, though, and it doesn’t matter how good a programmer we are—our functions will feel clumsy and awkward.
Get hands-on with 1400+ tech skills courses.