Introduction Flashcards
What are the three types of design patterns?
Creational, structural and behavioral.
What are the most common patterns?
Abstract factory, adapter, composite, decorator, factory method, observer, strategy and template method.
What are the essential four elements of a design pattern?
Name, the problem, the solution and the consequences.
What’s a signature?
The method name, its parameters and the return value.
What’s an interface?
A set of all signatures defined by an interface type.
What’s dynamic binding?
It means you’re not committing to an object implementation until runtime.
What’s polymorphism?
Allows you to substitute implementations in run time.
What’s an object?
An instance of a class.
What’s an abstract class?
It will defer some or all of the implementations.
What’s a concrete class?
Class that implements all methods. Differently than abstract classes.
What are the disadvantage of inheritance?
Class inheritance is defined at compile time, not runtime;
it breaks encapsulation;
And changing parent classes may impact child classes.
What are the advantages of inheritance?
Straightforward to use and easy to modify parent’s functionality.
What are the advantages of composition?
Defined at run time;
Do not break encapsulation;
Objects can be changed freely as long they implement the same interface;
Promove loose-coupled system
What are the oriented object principles?
Program to an interface, not an implementation;
Favor object composition over inheritance;
What’s a delegation?
It’s when you simply forward the request to a private composite class and return its return.
What’s aggregation?
Aggregation means that one object contains or owns another object and both have the exact lifetimes.
What’s acquaintance?
Acquaintance means one object merely knows the other object. These object request operations from each other, but not responsible for each other.
What’s a toolkit?
Set of common functionalities usually provided by the language in order to preventing the programmer from re-inventing the wheel. Emphasizes code re-use.
What’s a framework?
A set of cooperating classes. It dictates the application design. Is pre-built for a range of applications (e.g: graphical editors). Frameworks emphasize design reuse.
How to select a design pattern?
Consider what should be variable in your design;
Examine the cause of the redesign;
Consider how design pattern solve design problems;
Study how design patterns interrelate and their purpose;
Check the intent of all design patterns;
When a design pattern should be applied?
When the flexibility it affords is actually needed.