What is Container In POO?

5

What is Container in object-oriented programming in which scenario your usage is best represented?

    
asked by anonymous 16.03.2017 / 01:41

3 answers

6

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 certainly applies 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 non-scalar objects, that is, objects that are composed of other objects. They are various data structures that carry scalar objects or other structures, so it can contain other containers as well. Obviously a scalar object is the object itself and contains nothing but itself.

A reference can 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 most obvious containers are collections, such as the array that has a data string.

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 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 confection.

    
16.03.2017 / 03:19
3

Container in OOP is usually used to refer to the dependency injection mechanism that has the resolution of all dependencies. In case it is a dependency injection container. Dependency injection part of the principles of SOLID

    
20.04.2017 / 15:35
0
In object-oriented programming, Container is an abstract delimiter, that is, an object that contains other objects that can be dynamically added or removed (during runtime), unlike what occurs in a composition where this relationship is fixed during compile time. Is your usage best represented? it depends on what you intend to use.

    
03.07.2018 / 03:02