Design Patterns Flashcards
What are Software Patterns?
Standard solution to a recurring problem.
These solutions are successful and patch common problems.
This discipline emerged from the Object oriented community
What are the essentials of a software pattern?
- Pattern Name: A handle used to describe the problem.
- Problem: Explains context and how to apply pattern
- Solution: Described elements, relationships, responsibilities and collaborators.
- Consequences: result and tradeoffs, impact on flexibility, extensibility or portability
What are the classifications of Software patterns
- Design patter: described by means of design constructs. Objects, classes, inheritance, aggregation, uses relationships.
- Architectural Patterns: structural organization or schema for software systems. Set of predefined subsystems, responsibilities and inter-relationships
- Idioms: Pattern whose form described by means of programming language constructs.
Explain the Factory design pattern
intent, structure, interface
Useful when base class of object is known but the subclass it belongs to is only known at run time when user provides input.
Structure: a superclass specifies all standard and generic behaviour. Delegates creation details to subclasses.
Interface: Client code needs an object of particular class. Calls a method known as factory class that instantiates the object.
Explain the Abstract Factory design pattern
intent, structure, interface
Provide interface for creating families of related or dependent objects without specifying concrete classes.
Structure: Uses a class to collect coordinated factory methods in one place, one class per style. Base class is named abstract factory, each subclass interprets its factory methods to produce objects of a single style.
Interface: client only interacts with abstract classes and never create objects directly.
Explain the Observer pattern
Underlying data is known as the observable and the views are known as the observers.
Define Software Architecture
High level design enabling engineers to understand overall structure of a project.
Define Architectural Patterns
Description of a set of predefined subsystems and their responsibilities.
Rules and guidelines for organizing the relationship among subsystems
Explain the Layered Architectural pattern
Structure applications that can be decomposed to subtasks. Each task an abstraction, each layer a service to the next layer. Each higher service uses a layer directly below.
Benefits of Layered Architectural pattern
- lower level services can be used by many higher level services.
- Inter layer changes do not affect other layers and each layer can be replaced by a different implementation.
- Clearly defined levels of abstraction
Explain the Client-Server Architectural Pattern
Server component provides services to many clients.
Client requests services from server.
Server always listening for requests from client.
Ex: remote DB access, web based apps.
What are some limitations of Client-Server Pattern
- Communication overhead
- Could require data transformation between data layer and server.
What are the different sessions of a Client-Server setup?
Stateless Server: Session state managed by client.
Stateful Server: Session state maintained by the server, associated with a client id.
Explain the Master-Slave Architectural Pattern
- Supports parallel computation and fault tolerance.
- Work distributed among identical components.
- Master computes the final result from the returned work.
Ex: Process control, Embedded systems
Explain the Broker Architectural Pattern
- Servers provide services.
- Servers publish capabilities to a broker.
- Clients request a service from a broker who picks a server from their published capabilities
- Broker redirects client.
- An Interface Definition Language (IDL) specifies the interface between the client and server. Then a Remote Procedure Call (RPC) mechanism, creates the code stubs to call functions across a network.
Think about CORBA and other web services.