Skip to content

Glass Onion Codebase

Posted on:January 3, 2023 at 12:13 PM

“I like the glass onion, as a metaphor. An object that seems densely layered, but in reality, the centre is in plain sight.”

One of the most important concepts in code is picking the right abstraction. Test first development from a user behavior perspective helps us get to the right abstraction sooner.

Over time, the API surface area of any abstraction may increase, purpose can shift, and we can go from transparency, to muddy.

Keeping the glass onion in mind is helpful to remember that while we strive to make abstractions to gain efficiencies in maintenance, reliability, and accurage representation of the domain model, we must also ensure that these benefits are not overshadowed by obfuscation.

A good glass onion codebase lets engineers “see through” the abstraction to quickly understand what’s happening underneith without having to dig through obscure tangles of code.

Good typing, good naming, good file structure, and frequent refactoring to fit a ubiquitous language and domain model are all great for creating a glass onion codebase.