O'Reilly logo

Elixir in Action by Saša Jurić

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4. Data abstractions

This chapter covers

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

This chapter deals with building higher-level data structures. In any complex system, there will be a need for abstractions such as Money, Date, Employee, and OrderItem, 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 data abstractions.

In a typical OO language, the basic abstraction building blocks are classes and objects. For example, there may be a String ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required