Encapsulation is a pillar of object-oriented programming, but how important is it in the context of functional programming? Is it worth clinging to, or should we stay away? This talk will examine the tradeoffs of encapsulating internal representations versus exposing the “nature” of our data.
Programming with immutable values and algebraic data types usually makes hiding fields behind accessors unnecessary. On the other hand, hiding functions and types is a crucial technique control our API, encouraging correct usage and affording the flexibility to change it.
In this session we will explore constraints that encourage encapsulation, discuss how it affects our types, their algebras, and their algorithmic properties, and learn about alternatives and their benefits and drawbacks.
Martin Kühl is a senior consultant at innoQ. He is interested in programming languages, styles, and tools, and strives for clarity, simplicity, and generality.