133k views
5 votes
Match the context details with the pattern that applies.

An object contains other objects (elements) and must give access to them for clients, without exposing its internal structure.
A subject object generates events and one or more objects need to be notified when an event occurs.
An object could use different variations of an algorithm and the client of that object wants to supply a custom version of that algorithm.
An object aggregates primitive objects and clients treat the aggregate object as a primitive object, too.
An object's behavior must be enhanced without adding more responsibilities to it.
Observer, iterator,decorator,strategy,composite

1 Answer

3 votes

Answer:

1. - Observer

2. - iterator

3. - strategy

4. - composite

5. - decorator

Step-by-step explanation:

An object contains other objects (elements) and must give access to them for clients, without exposing its internal structure. This is an observation.

The subject-object can generate events as an iterable (iterator) and could use different strategic algorithms to achieve a task. Class objects can be used to aggregate other class objects.

In python, the decorator function mimics the outer function of a nested function, but still maintains the functionality of the second function

User OptimizedQuery
by
4.1k points