What is the Singleton Design Pattern?
When you limit your application to only a single instance of a class and making it globally accessible.
What are the benefits of the Singleton Design Pattern?
Allows for you to have a single point of truth for a given class.
What are some ways you can use a singleton?
Application state, technology drivers, application configuration objects
Some consider the singleton design pattern an anti-pattern, why?
How do you make a singleton?
Make the constructor private and provide a public static method that is responsible for providing only a single instance of the class. If it already has an instance then return the already created instance instead of a new instance.
What is the Facade Pattern
Provides a high level interface that makes the subsystem easier to use such that a client interacts with the facade rather than the complexity of the subsystem itself.
The facade may know how to handle a potentially complex setup or interaction with the code in question so that the client doesn’t have to know how to itself.
What is the Decorator Pattern
Using composition instead of inheritance to share behavior by attaching additional responsibilities to an object dynamically (at runtime).
“is a” and “has a” of a the same type.
What’s an advantage of the decorator pattern over inheritance?
What is a disadvantage of the decorator pattern?
In a decorator what does “this” refer to?
It refers to the member variable that is the composition of the decorator type (i.e. this.beverage()).
What are some scenarios where it makes sense to use a decorator pattern?
Input Stream, ie. FileInputStream, BufferedInputStream, etc…
What is an adapter pattern
Let’s classes work together that couldn’t otherwise because of incomparable interfaces.
What are some examples of when it makes sense to use an adapter pattern?