Design Patters Flashcards

1
Q

Why should we use design patterns?

A

We should use design patters since they increase code reuse by using common abstraction techniques.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is model view controller

A

Separates presentation and interaction from system data.
- Model: system data and operations on that data
- View: how the data is presented to the use
- Controller: Manages user interaction (clicks, etc) with data.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is problem description

A

describes when the design pattern is needed

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is solution description:

A

Explains what the solution is

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the 3 types of design patterns?

A

Creational, Structural, Behavioral

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is creational design patterns

A

Abstracts the object instantiation process

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are some common creational patterns

A

Abstract factory
builder
factory method
prototype
singleton

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is factory method

A

Problem description:
- use when a class cannot anticipate the objects it must create.
Solution description:
- Defers the responsibility of creating objects to subclasses that know what to create.

example: pizza class has 3 sub classes : cheese, greek, peperoni

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is abstract factory

A

problem description:
- Use when your system must be configured with one of multiple families of objects
Solution description:
- Creates abstractions that hide the configuration details of the object families.

One store will create two types:
- Ny store will create ny borgar and ny pizza
another store will create:
- chicago store will create chicago borgar and chicago pizza

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are composite

A

Problem description: (STRUCTURAL)
- use to allow clietns to treat individual obkects and collections of them identically.
Solution description:
- Use an abstraction to hide the fact that an object is an aggregate of several objects.

Leaf-node relationship, directory and files

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the template method

A

Problem description: (BEHAVIOURAL)
- Used to share common parts of an implementation while allowing subclasses to refine other parts.
Solution description:
- Common parts are defined in the superclass, which makes calls to abstract methods that deliver the other parts.

example: meal class is abstract, and combo1(), combo2() extend meal. and override the entree(), maincourse() and desert() methods.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the YAGNI principle.

A
  • “You Aren’t Going to Need It”
  • Design for the system you need today
  • Revisit design periodically for opportunities to refactor and improve
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is cohesion and coupling

A

Cohesion is the degree to which a module relies on other members within the module to deliver its functionality.
- Keep HIGH

Coupling:
Degree to which a module relies on other modules to deliver functionality
- keep LOW

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are Structural patters

A

Structural:
Abstracts how classes and objects are composed to build larger structures

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are Behavioural patters

A

Behavioural:
Abstracts algorithms and assignment of responsibility among objects

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are 7 types of structural patterns

A

skip

16
Q

What is cohesion

A

Degree to which a module relies on other members within the module to deliver its functionality
Desirable to keep HIGH

17
Q

What is coupling

A

Degree to which a module relies on other modules to deliver functionality
Desirable to keep LOW

18
Q

What is a schizo class

A

Problem description:
A class that contains disjoint sets of public methods that are used by disjoint sets of client classes
Solution description:
Refactor each set of methods into individual classes

19
Q

What is a blob class

A

Name:
Blob (aka: god class)
Problem description:
A large class that is lacking cohesion or makes most of the processing decisions
Solution description:
Refactor Blob classes into a series of more cohesive classes