lovespring
lovespring

Reputation: 19559

Is "container" and "context" a kind of design pattern?

In java, I have see so many "container" and it provide "context" to it's client.

Such as EJB container, Web Container, IoC/DI container and "ApplicationContext".

Is this concept a kind of design pattern? I have searched in GoF, and it seems didn't

describe a thing like this.

Upvotes: 2

Views: 177

Answers (3)

peter.petrov
peter.petrov

Reputation: 39437

The GoF book is about OO design patterns, it was published in 1995
before all these Java enterprise patterns and servers came up.
It is at the level of classes, methods, etc. i.e. about OO concepts.

You may consider containers and contexts some sort of patterns, yes.
But they are about modules, components, containers, servers, and how
to make these modules and components run into containers and servers.
These are just things from a different time and at a different level.

Upvotes: 0

Gabriel Aramburu
Gabriel Aramburu

Reputation: 2981

Instead of 'design pattern' a more suitable concept for 'Container' is Framework.

... a software framework is an abstraction in which software providing generic functionality can be selectively changed by additional user-written code, thus providing application-specific software. A software framework is a universal, reusable software platform to develop software applications, products and solutions. ...

In java, I have see so many "container" and it provide "context" to it's client.

'Context' is the environment execution information provided by the Container to the Components that run on it. With the previous definition in mind you can see the 'Context' as one of the generic functionality provided by the Container. More clear, you have a Container that runs components, each component access the environment information through the Context. Of course this not pretend to be a formal definition, it is just the way I like to think about this concept.

Upvotes: 0

Kayaman
Kayaman

Reputation: 73528

Not a design pattern, more of a design construct (well, I guess you could argue that the difference is in semantics). A Container would provide an environment (i.e. external code) for your code to run in, and a Context would provide environment settings and additional information for your code.

Upvotes: 2

Related Questions