Balanced Abstraction Principle
Sandro Mancuso, in his blog, defines the Balanced Abstraction Principle as follows:
The Balanced Abstraction Principle defines that all code constructs grouped by a higher-level construct should be at the same level of abstraction. That means:
- All instructions inside a method should be at the same level of abstraction.
- All public methods inside a class should be at the same level of abstraction.
- All classes should be inside a package/namespace.
- All sibling packages/namespace should be inside a parent package/namespace.
Sandro Mancuso, Balanced Abstraction Principle, https://codurance.com/2015/01/27/balanced-abstraction-principle/.
Let's see how it relates to a little previous example. In the following snippet, the Save
method is not at the same level of abstraction:
public class Car{ public int CurrentMileage(){...} public void TravelTo(Location location){...} public void Save...