What is Container in POO?

Asked

Viewed 956 times

10

What does Container mean in object-oriented programming? In which scenario its use is best represented?

  • 1

    Can you give a context? It’s not such a term used, Leo less for it.

3 answers

9


I have not seen the term being used specifically for object orientation, although it can be used because it is something so fundamental that it is certainly applied to OO.

Container is something that contains things. It is a place to store and eventually carry some things. In programming we can call container all nonscalar objects, i.e., objects that are composed of other objects. They are diverse data structures that carry scalar objects or other structures, so they may contain other containers also. Obviously a scalar object is the object itself and contains nothing but itself.

A reference may be a container since the same value is another object. Structures and classes, among other types can be considered containers because they have one or more data inside it. The containers the most obvious are the collections, such as array which has a data sequence.

Some say it’s just a dynamic structure or a collection of data.

Some languages may use the term more specifically.

On the other hand the term can be used in some specific domain, for example in GUI, a control can be a container for other controls. This would be related to OOP since almost every GUI uses this paradigm in its making.

5

POO container is usually used to refer to the dependency injection mechanism that has the resolution of all dependencies. In this case it is a dependency injection container. Dependency injection starts from the principles of SOLID

1

In object-oriented programming, Container is an abstract delimiter, i.e., an object that contains other objects that can be included or removed dynamically (during runtime)unlike what occurs in a composition where this relationship is fixed during the compilation time. Scenario your use is best represented? it depends on what you intend to use.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.