Container (design pattern)

from Wikipedia, the free encyclopedia

The container - design pattern used in software development. It is classified in the group of structural patterns.

use

The container design pattern divides the application logic into two parts. On the one hand, a component is required which specifically fulfills its main task. An associated container provides the component with all the necessary interfaces to other systems. An extension is that the components in the container can be added or removed as required at runtime. This design pattern is not an original GoF pattern .

Java EE

The design pattern takes place e.g. B. in the Java EE heavy use and is an essential part of it. Many services of the Java EE are constructed with this pattern. For example the web container , which contains servlets . Other examples are EJB containers or JMS providers .

Components

A component encapsulates logical information / routine of the overall system. It can be changed at runtime or interact with other components (possibly from other containers).

Each container can contain certain components. The components are completely encapsulated and any requests or events are forwarded to them by the container. Under certain circumstances, the container itself takes care of instantiating the components with certain routines.

advantages

  • The principle of encapsulation is strongly supported
  • The complexity of the system for further development is extremely reduced
  • Changes to the components are relatively easy
  • High testability, changeability and stability

disadvantage

  • Sometimes higher effort in developing the container
  • A clear definition of the interface between container and component is necessary

See also