One of the best known models of how interactions can be modeled and worked on is the OSI/ISO model that describes the interaction of layers in the networking stack. It comprises seven layers, each with a well-defined interface to be communicated with by the layer above, and to communicate with the layer below. Furthermore, each layer defines a protocol that allows it to communicate with a layer of the same level. With this in place, there is a very clear API to communicate with the layer and it is also clear how the layer can call back out to the system, therefore making it easy to replace parts of the system. The following diagram shows this how it is described in the OSI/ISO model. Each layer is defined by a protocol that allows instances on each side to communicate at their layer, as we move up the stack protocols are wrapped and unwrapped by the given instances:
This model has not been adopted across the board of course, with TCP/IP focusing on five layers, and...