Sof Dev - Design Patterns Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is the Factory Pattern?

A

A creational design pattern that provides an interface for creating objects in a superclass but allows subclasses to alter the type of objects that will be created.

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

What are design patterns?

A

Design Patterns are meant to provide a general reusable solution to one type of problem during software development.

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

What are the four parts of the Factory Pattern?

A

Product Interface: Declares the interface for the product created by the factory.
Concrete Products: The actual objects that implement the product interface.
Creator Class: Declares the factory method that returns an instance of the product interface. It may also contain additional business logic.
Concrete Creator Subclasses:
Implement the factory method to create specific instances of the concrete products, thus defining the type of objects the factory will produce.

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

What is the abstract factory pattern?

A

Abstract Factory is a creational design pattern that lets you produce families of related objects without specifying their concrete classes.

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

What are the five parts of the abstract factory pattern?

A

Abstract Factory Interface:
Declares the interface for creating product objects.
Concrete Factories:
Implement the Abstract Factory interface to produce families of related products.
Abstract Product Interface:
Declares the interface for a type of product object.
Concrete Products:
Implement the Abstract Product interface, representing specific product variants.
Client:
Uses the Abstract Factory and Abstract Product interfaces to interact with families of related products without being aware of their concrete classes.

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

Factory Pattern vs Abstract Factory Pattern

A

While the Factory Pattern uses inheritance and gives a complete object in one go, the Abstract Factory Pattern uses composition and returns a family of related classes.

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