I have been thinking a lot lately about how code gets organized in a layered way. I have been thinking of four different ways:
- Instantiation -- specifically objects are instances of classes. However, in several languages (like python), classes are also objects that were instantiated from a metaclass. So you can end up with an instance stack of objects.
- Inheritance -- you end up with a stack of super classes. Even when you have multiple inheritance you end likely have a way to turn it into a stack (like the MRO in python).
- Namespaces -- scope is typically layered too.
- Calls -- the call stack is probably the most familiar and the oldest conceptually. It is the mainstay of programming.
You could argue that instantiation is just a different sort of call stack, and that inheritance is just another namespace stack, but regardless these are what I thought of.
So does anyone have any other conceptual stacks that fit in here, or do calls and namespaces sum it all up? Any other thoughts?