3 ms·
IMHO, encapsulation is a principle that can also be applied to non-traditional OOP or even FP, even when there is no mutable state. It's mostly about limiting
by Tainnor 4y ago
IMHO, encapsulation is a principle that can also be applied to non-traditional OOP or even FP, even when there is no mutable state.
It's mostly about limiting the knowledge that certain parts of the program need to have about the internals of certain other parts of the program. For example, if I want to use Redis as a cache, I can make sure to only do so via a specific set of functions and data structures from a particular class/module/... that don't expose any lower-level details.
- daxfohl 4y agoAgreed. Having worked in F# for a few years, I still find encapsulation extremely useful for things like the logging problem discussed in the article. (Another advantage is the ability to specify configurations via IoC frameworks or bespoke options).
- agumonkey 4y agoIndeed, encapsulation is probably better referred to a minimal coupling. Near zero knowledge interaction. It's a variability principle.