Design Patterns Flashcards

1
Q

What are Design Patterns?

A

A design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. A design pattern is not a finished design that can be transformed directly into source or machine code. It is a description or template for how to solve a problem that can be used in many different situations. Patterns are formalized best practices that the programmer can use to solve common problems when designing an application or system

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

What all are the advantages of Design Patterns?

A

Patterns solve software structural and non functional problems.

Structural problems like:

Abstraction
Encapsulation
Data Hiding
Separation of Concerns
Separation of Interface and Implementation
Single point of reference
Coupling and Cohesion etc..
Non Functional problems like:
Efficiency
Reliability
Interoperability
Testability
Reusability etc..
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What all are the types of Design Patterns?

A

There are 3 types of Design Pattern.

Creational Patterns
This type of pattern address problems of creating an object and separating it from operations
Structural Patterns
This type of pattern address problems of using object oriented constructs to organize classes and objects
Behavioral Patterns
This type of pattern address problems of assigning responsibilities to classes

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

What is Structural Design Pattern?

A

Structural patterns are concerned with how classes and objects are composed to form larger structures; the class form of the Adapterdesign pattern is an example.

Structural class patterns use inheritance to compose interface or implementations.

Structural Design Patterns are Design Patterns that ease the design by identifying a simple way to realize relationships between entities.

In C#, We have 7 types of design patterns in Structural Catagory.

Adapter
Bridge
Composite
Decorator
Facade
Flyweight
Proxy
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is Singleton Design Pattern?

A
Singleton ensures a class only has one instance.
Singleton Provides a global point of access to it.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is Factory Design Pattern?

A

Factory Design patterns:

Define an Interface for creating an object but let subclasses decide which class to instantiate
Lets a class defer instantiation to subclasses
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is Abstract Factory Design Pattern?

A

Provides an interface for creating families of related or dependent objects without specifying their concrete classes.
Abstract Factory patterns acts a super-factory which creates other factories. This pattern is also called as Factory of factories

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

What is Prototype Design Pattern?

A

Prototype pattern specifies the kind of objects to create using a prototypical instance, and create new objects by copying this prototype.
It is used to create a duplicate object or clone of the current object to enhance performance.

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

What is Builder Design Pattern?

A

Separate the construction of a complex object from its representation so that the same construction process can create different representations.
In other words,you will have to design the system in such a way that the client application will simply specify the parameters that should be used to create the complex object and the builder will take care of building the complex object.

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

What is Adapter Design Pattern?

A
The adapter pattern is adapting between classes and objects
This pattern involves a single class called adapter which is responsible for communication between two independent or incompatible interfaces
This works like a bridge between two incompatible interfaces
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is Bridge Design Pattern?

A
Bridge Pattern separates abstraction from its implementation, so that both can be modified Independently
Bridge Pattern behaves like a bridge between abstraction class and Implementer class.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is Composite Design Pattern?

A
Composite pattern composes objects in term of a tree structure to represent part as well as whole hierarchies.
Composite pattern creates a class contains group of its own objects. This class provides ways to modify its group of same objects.
Composite pattern is used when we need to treat a group of objects and a single object in the same way
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is Decorator Design Pattern?

A
Decorator pattern is used to add new functionality to an existing object without changing its structure.
Decorators provide a flexible alternative to subclass for extending functionality.
This pattern creates a decorator class which wraps the original class and add new behaviors/operations to an object at run-time.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is Facade Design Pattern?

A

Facade Design Pattern makes a software library easier to use, understand and test
Facade Design Pattern make the library more readable
Facade Design Pattern reduce dependencies of outside code on the inner workings of a library
Facade Design Pattern wrap a poorly designed collection of APIs with a single well-designed API.

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

What is Flyweight Design Pattern?

A

Flyweight design pattern is an object that minimizes memory use by sharing as much data as possible with other similar objects
Flyweight pattern is used to reduce the number of objects created, to decrease memory and resource usage. As a result it increase performance
Flyweight design pattern provides a way to use objects in large numbers when a simple repeated representation would use an unacceptable amount of memory.
The flyweight pattern uses the concepts of intrinsic and extrinsic data.Intrinsic datais held in the properties of the shared flyweight objects. This information is stateless and generally remains unchanged, if any change occurs it would be reflected among all of the objects that reference the flyweight.Extrinsic data is computed on the fly means at runtime and it is held outside of a flyweight object. Hence it can be stateful.

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

What is Proxy Design Pattern?

A

Proxy Design pattern involves a class, called proxy class, which represents functionality of another class.
Proxy is a wrapper or agent object that is being called by the client to access the real serving object behind the scenes.

17
Q

What is Creational Design Pattern?

A

In software engineering, creational design patterns are design patterns that deal with object creation mechanisms, trying to create objects in a manner suitable to the situation.

In C#, we have 5 types of Design Patterns in Creational Catagory.

Singleton
Factory
Abstract Factory
Prototype
Builder