Easier encapsulation with static types
GOTO Copenhagen 2024

Thursday Oct 3
16:30 –
17:15
Room 2

Easier encapsulation with static types

Human short-term memory is notoriously limited, which makes it difficult for us to keep much code in our heads at a time. A common solution to this problem is encapsulation, which alleviates the problem by shielding you from having to know intimate implementation details of code that you use.

But how do you communicate the essentials of an API to a client programmer? May this method return null? Can I call it with an empty collection? Would a negative number be an appropriate argument?

Static types offer a solution to many such API design problems. Through the use of metaphor and a few code snippets, I'll make the argument that static types make encapsulation easier to attain.