Podcast
Questions and Answers
What is the Adapter Pattern used for?
What is the Adapter Pattern used for?
- Modifying the source code of a class
- Converting the interface of a class into another interface the client expects (correct)
- Testing the compatibility of interfaces
- Creating an abstract base class for shapes
Why might we need to use the Adapter Pattern?
Why might we need to use the Adapter Pattern?
- To change the interface of a class
- To create an intermediate adapter object
- Because the interface of an existing class is incompatible with the interface needed by the client (correct)
- To avoid re-programming a class
Which type of behavior do shapes (points, lines, squares) in the Shapes Library have in common?
Which type of behavior do shapes (points, lines, squares) in the Shapes Library have in common?
- Serialization, deserialization, compression
- Display, fill, undisplay (correct)
- Access control, encapsulation, inheritance
- Rotation, scaling, translation
What principle does the Solution (Design to interface principle) in the example follow?
What principle does the Solution (Design to interface principle) in the example follow?
Why should we create an abstract base class for shapes according to the text?
Why should we create an abstract base class for shapes according to the text?
What is one reason why we cannot change the interface of an existing class?
What is one reason why we cannot change the interface of an existing class?