Design Patterns Flashcards

1
Q

What is Design Patterns ?

A

Design patterns are solutions for problems faced during software development , they are best practices used by developers.

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

What is GOF (Gang Of Four) ?

A

GOF are 4 authors Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides published a book titled Design Patters - Elements of Reusable Object-Oriented Software which initiated concept of Design Patterns in software development.

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

What are design patterns based on?

A

*Program to an interface not implementation
*Favor object composition over inheritance

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

What is usage of design patterns ?

A

*Common platform for developers: Standard terminology and are specific to a particular scenario.
*Best practices

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

How many Design Patterns we have ?

A

23

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

Types of Design Patterns

A

*Creational Patterns
*Structural Patterns
*Behavioral Patterns
*J2EE Patterns

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

What are Creational Patterns ?

A

Creational Patterns provides a way to create object while hiding creation logic rather than using instantiation with new operator.
=>Benefits: Increase flexibility + reusable code

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

What are Structural Patterns ?

A

Structural Patterns consist on assembling objects and classes to larger structures , while keeping these structures flexible and efficient

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

What are Behavioral Patterns ?

A

Behavioral patterns are concerned with communication between objects.

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

What are J2EE Patterns ?

A

J2EE Patterns are concerned with the presentation tier

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

What is Factory Pattern ?

A

Factory is a creational pattern that provides an interface for creating objects in a super class, but allows subclasses to alter the type of objects that will be created.
Extends Abstract Factory class (not yet a certain factory , its true nature not revealed yet )
_________________________________________________
Examples:
*We have a Shape Factory we created Circle , customer want a Rectangle that’s where Factory pattern come , it creates the alter the shape independently of the other using Shape interface.
_________________________________________________
IS this correct ??? :
*We have a burger without knowing it’s ingredients
_________________________________________________

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

What is Abstract Factory Pattern ?

A

is a creational pattern for producing families of related objects without specifying their concrete classes.
it’s working around a super factory which creates other factories.
________________________________________
Example:
Creating an AbstractFactory containing RoundedShape and SimpleShape Factories , RoundedShape Factory to create
products with rounded shape ,same for SimpleShape Factory, which construct shape (interface) that contains all shapes.

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

What is Builder Pattern ?

A

Builder is a creactional pattern, for creating complex objects step by step. To produce different types and representations of an object with the same construction code.
*We have control over ingredients used to construct our burger

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

What is Singleton Pattern ?

A

Singleton is a creational pattern, that let you ensure that a class has only one instance while providing global access to this instance (Single Responsibility Principle), and provide a way to access an object without the need to instantiate it.
=>instantiate one time the only object inside class , if it change all components that use it change there object value

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

What is Observer Pattern ?

A

Observer is a behavioral pattern,
*Come to picture when singleton updates all its components in real time
*PubSub : when a user publish a video on youtube , youtube notify all subscribers

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

What is Iterator Pattern ?

A

Iterator is a behavioral pattern
* construct an iterator , for linkedlist, tree…

17
Q

What is Strategy Pattern ?

A

Strategy is a behavioral pattern,
*OCP (open closed principle ):open to extensibility , closed to modification

18
Q

What is Adapter Pattern ?

A

Adapter is a structural pattern,
When a Usb port can t enter a computer we use an adapter so it is convenient for Usb port

19
Q

What is Facade Pattern ?

A

Facade is a structural pattern,
*conceal unpleasant / credible reality with outward appearance
_____________________________________________
Examples:
*class and interface are outward and low level process is complex process
* ArrayList over an Array ( We don t need to worry about memory allocation )

20
Q
A