202410242306
Status: #idea
Tags: #software_engineering #design_patterns #computer_science #complexity
# Different layers should have different abstractions
Software systems are typically defined in layers, where higher layers use the abstractions defined by lower layers. As this hierarchy increases in size, the complexity due to class and function interfaces increases. This tradeoff is only worth it if the increased number of class and function interfaces produces a larger decrease in complexity in code implementation.
When different layers in the hierarchy have the same abstractions (i.e. their interfaces are the same), this typically indicates that the proliferation of classes & layers in the hierarchy is *not* worth the reduction in implementation complexity. This situation typically occurs when we create **pass-through methods** and **pass-through variables**.
Pass-through methods are methods in a higher-level class that provide no functionality other than calling a method of a lower-level class. Similarly, pass-through variables are variables that are passed to a method or class but not actually used in that method or class - instead, they are pass through to a lower level of the hierarchy.
In both cases, we create *more* interfaces while providing the *exact same* functionality as before, resulting in increased complexity for the full system. Hence, we should avoid these situations whenever possible.
See also: [[Complexity in software development and design]]
---
# References
[[A philosophy of software design]]