Patterns Flashcards

1
Q

What are the main categories of Design Patterns?

A

There are 3 different types of patterns:

  1. Creational patterns, such as Factory, Builder, Factory Method - they are all about different ways of instantiating object with non-trivial creation algorithm or unusual circumstances.
  2. Structural patterns, e.g. Proxy, Decorator, Bridge, Composite. This patterns identify common structures formed from language units and help to organize code into larger units in a comprehensible way.
  3. Behavioral patterns, e.g. strategy, command, chain of responsibility, template method, visitor. They specify a different kinds of interactions between language units.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is Singleton pattern?

A

Singleton pattern is a creational one. It facilitates a limitation of instances of particular type to at-most one. It can be used in cases where different execution threads should use the same state to work properly, but now it is more often used as an optimization technique to prevent repeated instantiation of a stateless class.

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

What is Design Patterns and why anyone should use them?

A

Design Patterns are industry-known and described best practice solution to common problems in software development. Patterns are a good communication tool for developers. Facing a correct pattern implementation may inform you about what problem had occurred here. Patterns are also a ready-to-go toolkit for solving trivial problems.

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

What is Factory pattern?

A

Factory is a class that is dedicated to creating an instance of another type. It mostly used when object creation logic is not simple and exact return type is not known at compile-time and depends on a result of some calculations.

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

What is Criteria pattern?

A

Criteria pattern is a way to make a set of conditions to filter out a collection of objects. This pattern allows to split collecting this conditions and applying them, it assumes presence of logical operators to make more complex filter chains and re-usability of particular filters.

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

What is Template pattern?

A

Template pattern is a abstract class that specifies the general behavior through the sequence of methods, but leaves an implementation of some of this methods to subclasses

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

What is State pattern?

A

State is a behavioral pattern that allows to change an object’s behavior by changing its state. Normally, that means presence of a context as an entry point which delegates whole or a part of execution to inner state implementation.

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

What is Inversion of Control?

A

Inversion of Control is an approach to design dependencies between classes through abstractions rather than concrete implementations of them. Concrete implementations are set in an outer level manually of with dependency injection mechanism.

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

What is Null Object pattern?

A

Null Object is a way to represent missing or unavailable data without utilizing default language null reference. Null Object is an instance of desired class or subclass of it, so, according to Liskov Substitution principle it should be usable in every situation where instance of original class could be applied.

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

What is Builder pattern?

A

Builder pattern is a way to create an object incrementally, providing different pieces of data separately from each other.

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

What is Strategy pattern?

A

Strategy is a pattern of picking required implementation of algorithm in runtime based on input data or stored data.

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

What is Iterator pattern?

A

Iterator pattern is a way to access elements of collection one by one by defining a custom method to proceed to the next element. Iterator can be applied either to real collections that have some kind of representation in memory or to virtual collections that can be only evaluated by iterating over them.

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

What is Proxy pattern?

A

Proxy pattern is a way to represent access to some remote service as simple as a call to a method of some interface

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

What is Dependency Injection?

A

Dependency Injection is a practice of separation between declaring abstract dependencies and providing concrete implementations that fit to this contract

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

What is Bridge pattern?

A

Bridge separates interface and it’s implementation to allow them evolve independently.

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

What is Facade pattern?

A

Facade is an entrypoint to scenario, which purpose is to wire up all different operations that need to be executed to complete this scenario.