Introduction Flashcards

1
Q

What are the three types of design patterns?

A

Creational, structural and behavioral.

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

What are the most common patterns?

A

Abstract factory, adapter, composite, decorator, factory method, observer, strategy and template method.

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

What are the essential four elements of a design pattern?

A

Name, the problem, the solution and the consequences.

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

What’s a signature?

A

The method name, its parameters and the return value.

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

What’s an interface?

A

A set of all signatures defined by an interface type.

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

What’s dynamic binding?

A

It means you’re not committing to an object implementation until runtime.

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

What’s polymorphism?

A

Allows you to substitute implementations in run time.

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

What’s an object?

A

An instance of a class.

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

What’s an abstract class?

A

It will defer some or all of the implementations.

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

What’s a concrete class?

A

Class that implements all methods. Differently than abstract classes.

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

What are the disadvantage of inheritance?

A

Class inheritance is defined at compile time, not runtime;
it breaks encapsulation;
And changing parent classes may impact child classes.

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

What are the advantages of inheritance?

A

Straightforward to use and easy to modify parent’s functionality.

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

What are the advantages of composition?

A

Defined at run time;
Do not break encapsulation;
Objects can be changed freely as long they implement the same interface;
Promove loose-coupled system

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

What are the oriented object principles?

A

Program to an interface, not an implementation;

Favor object composition over inheritance;

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

What’s a delegation?

A

It’s when you simply forward the request to a private composite class and return its return.

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

What’s aggregation?

A

Aggregation means that one object contains or owns another object and both have the exact lifetimes.

17
Q

What’s acquaintance?

A

Acquaintance means one object merely knows the other object. These object request operations from each other, but not responsible for each other.

18
Q

What’s a toolkit?

A

Set of common functionalities usually provided by the language in order to preventing the programmer from re-inventing the wheel. Emphasizes code re-use.

19
Q

What’s a framework?

A

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.

20
Q

How to select a design pattern?

A

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;

21
Q

When a design pattern should be applied?

A

When the flexibility it affords is actually needed.