Design Patterns Flashcards
What is a Design Pattern?
It is an organized way to present things or build things. Vocabulary for talking about things or building things. Separate the things that change and the things that don’t change. You are more efficient knowing this.
Architectural “Macroscale” Patterns?
You look at the growth structure from far away. Model view controller is an example of this. Pipe & Filter is an example of this. Pump -> Filter -> Filter -> Pump. Filters change the data. Event-based like in javacsript. Layering are all examples.
Gang of 4 Patterns?
Structural, Behavioral, and Creational.
23 Structural Design Patterns.
What is technical debt?
When you know the right thing to do is too long and instead you do the quick dirty option. Technical debt accumulates and makes anti-patterns. Viscosity, Dryness, Immobility, Needless reputation.
What is UML
Unified Modeling Language: notation for describing various artifacts in OOP systems.
DO inheritances follow Single Responsibility Class?
Yes we only let one model do a specific things. Even though they inherit.
What is Cohesion?
cohesion refers to the degree to which the elements of a module belong together. Thus, cohesion measures the strength of relationship between pieces of functionality within a given module. For example, in highly cohesive systems functionality is strongly related
Why doesn’t it work in javascript to call a method with no parenthesis?
it would be an expression whose value is the function itself, rather than a call to the function. It is becuase javascript functions are first class functions.
4 Categories of Maintenance?
- Corrective Maintenance where you repair and fix bigs
- Perfective Maintenance where you expand functionality
- Adaptive where you cope with changing environment
- Preventative where you improve the needs.
What is Composition?
The owned objects are usually destroyed when the owning object is destroyed.
What is aggregation?
Owned Object survives destruction of owning object.
How do you structure University to Departments in UML Model?
University has many departments, Departments have one University.
The Departments can’t survive without university, so composition.
What is the Single Responsibility Principle?
A class housed have one and only one reason to change. A sign is a data clump traveling with the calls to this class and a fix is to extract classes.
What is Open/Closed Principle?
You should be able to extend the behavior of classes without modifying existing code on which other classes or apps depend on it.
Difference between the Template Method Strategy & the Delegate Strategy?
Template Method is when the class has the basic game plan and then it is customized by delegating specific behaviors to the sub classes. In Decorator, each subclass provides functionality of its own, but delegate to the parent class for basic functionality.
Template - Class delegates behavior to descendants Decorator - Subclass delegate behavior to parent.