4 Data abstractions

This chapter covers

  • Abstracting with modules
  • Working with hierarchical data
  • Polymorphism with protocols

This chapter discusses building higher-level data structures. In any complex system, there will be a need for abstractions such as Money, Date, Employee, and OrderItem. These are all textbook examples of higher-level abstractions that usually aren’t directly supported by the language and are instead written on top of built-in types.

In Elixir, such abstractions are implemented with pure, stateless modules. In this chapter, you’ll learn how to create and work with your own abstractions.

In a typical object-oriented (OO) language, the basic abstraction building blocks are classes and objects. For example, there may be ...

Get Elixir in Action, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.