I think this is a very good question, because it makes us think about how we structure the software. Structuring software is necessary to create an abstraction layer between the code and its architecture.
Recently, I have come to the conclusion that horizontal layering is a convenient method, but vertical splitting is more useful . An example of horizontal layering is the classic DAL-> BAL-> GUI script, while vertical splitting divides the application into supported functions.
The stack model is obviously present in the horizontal stratification model. But also with a vertical breakdown of functionality, you can find a stack model. What I find particularly attractive with respect to vertical splitting is the idea that each of my vertical slices can have its own stack of horizontal layers, an idea that looks like models that are becoming increasingly popular, like CQRS. There may also be dependencies between the vertical sections of your application, which again are modeled as a stack. But sometimes this is not enough , and you need a more complex abstraction than a stack like graph .
Distracting from this, I think that the reason we like to think in stacks is that we can see things at different levels of abstraction by clicking / stack on demand. Other structures, such as Graphs , are sometimes more suitable for describing problems, such as dependencies between components, but they are more complex and therefore not as convenient as stacks.
This is also the reason why multiple inheritance was imposed: a dependency graph (multiple inheritance) is much more difficult to understand than a simple stack (single inheritance).
What else can be modeled as a stack? Honestly, I think we have a lot here, and you are very far away:
- Hierachies inheritance (single inheritance)
- horizontal, architectural layers
- vertical architectural layers (component)
- simple, linear relationships (call sequences, wrappers, facades)
source share