Class Work – Self Learning (17/2/2026)
Topic: Software pattern
Read [Link]
Based on this, answer the following questions:
1. Identify the names of the following design patterns:
a. Offers a high-level interface that makes a system easier to use.
b. Ensures that a class has, at most, one instance and provides a unique access point to it.
c. Facilitates the construction of complex objects with various attributes, some of which
are optional.
d. Converts the interface of one class into another interface that clients expect. This
pattern allows classes to work together when it would not be possible due to the
incompatibility of their interfaces.
e. Offers an interface or abstract class for creating a family of objects.
f. Provides a method to centralize the creation of a type of object.
g. Serves as an intermediary that controls access to a base object.
h. Allows adding new functionalities dynamically to a class.
i. Provides a standardized interface for navigating data structures.
j. Allows changes in the algorithms used by a class.
k. Makes a data structure open to extensions, allowing the addition of a function to each
element without changing their code.
l. Allows an object to notify other objects when its state has changed.
m. Defines the skeleton of an algorithm in a base class and delegates the implementation of
some steps to subclasses.
2. Considering the answers to question (1), list design patterns that:
a. Make a class open to extension without needing to modify its source code, i.e., patterns
that put into practice the Open/Closed principle.
b. Decouple two kinds of classes.
c. Increase a class’s cohesion, i.e., ensure the class has a single responsibility.
d. Simplify the use of a system.
3. What is the similarity among Proxy, Decorator, and Visitor? And what is the difference
between these patterns?
4. Suppose we have a base class A. Now assume we want to add four optional features F1, F2,
F3, and F4 to A. These features can be added in any order, i.e., the order is not important. If we
use inheritance, how many subclasses of A would we need to implement? And if we use a
solution based on decorators, how many classes will we have to implement (not counting class
A)? Justify and explain your answer.