Detailed design Flashcards
What is the 3,1,2 process for solving design problems?
Can be used individually, but often work nicely in concert, in the order ③, ①, ②
- Program to an interface, not an implementation. (Let clients depend on what the code does, not how it is actually implemented. Why? This allows the implementation to change without affecting the clients. Forces you to think of responsibilities.)
- Favor object composition over class inheritance. (Why? Composition-based designs are more flexible)
- Consider what should be variable in your design. (Q: What is varying? A: The strategy for reading/writing (simple, distributed, etc.) => We encapsulate the two in the Twitter class. Now all behavior that regards reading / writing is in one place.)
Description:
1. The question is then whether the class construct is the best way to define a contract between a server and its client. In many cases, the answer is “no!” It is better to program to an interface.
- Class inheritance is the mechanism whereby I can take an existing class that has some desirable behavior and subclass it to change and add behavior. Object composition is, in contrast, the mechanism whereby I achieve complex behavior by composing the behavior of a set of objects.
- Instead of considering what might force a design change you must focus on the aspects that you want to vary—and then design your software in such a way that it can vary without changing the design.
What is the intensionality/locality thesis?
= Guideline to distinguish between architecture, design and implementation.
Architecture | Intensional | Non-local
Design | Intensional | Local
Implementation | Extensional | Local
What are the 12 design patterns?
Strategy, state, abstract factory, facade, decorator, adapter, builder, state, command, proxy, composite, observer
What is detailed design?
In detailed design, we are working closer to the implementation level.
The goal is to define how to implement software architecture.
Since we are close(r) to implementation level, techniques are not (necessarily) paradigmindependent.
What is system design?
The process of defining the architecture, components, interfaces, and other
characteristics of a system or component
What is the difference between detailed software design and software architecture?
Software architecture is concerned with describing the overall structure of
systems.
Software design is concerned with describing each component in such a detail
that it may be constructed.
Architecture, design, implementation: What is design models?
Abstractions for reasoning about certain structural aspects of software
* Relevant for discussion in software design & architecture
* First-order, finite structure in mathematical logic
* Consist of atoms and relations among atoms
E.g. LogDectorator is a Class atom, LogDecotrator.getTweets is a Method atom, and Extends is a Relation.
Architecture, design, implementation: What is specifications?
Specifications = the set of formal languages of any order
* They include programming languages (e.g. Java, Haskell) and specification languages (e.g. Z, UML)
* Their semantics are described by design models
Architecture, design, implementation: What is intensionality vs extensionality?
A specification is said to be intensional if there are infinitely many possible instances
of it. Otherwise, it is said to be extensional.
An implementation (e.g., the previous Java program) is extensional
* As a specification, an implementation is only associated with one design model
Designs (e.g., design patterns) are intensional
* Their definition include free variables
– E.g., in Abstract Factory, the exact interface of the Abstract Factory participant
does not matter (it is a free variable)
Architecture, design, implementation: Non-locality
Non-local specifications pervade all parts of a system.
Architectural decisions are usually concerned with the entire system => non-local
i.e., all possible “implementations” of an architectural specification must meet the
architectural specification.
E.g., the universal base class rule for C++: all classes, c, must satisfy Inherit*(c, Object)
not required by the language but by certain systems, teams
Local specifications can be satisfied in “some corner” of our program without this
being affected in how the rest of the program is like.
What is layered architecture?
Layered Architecture: “high-level components depend on low-level components to
perform their functionality & you can’t jump layers”.
We may formalize layered architecture rules as a specification:
* For all classes, c, there exists one layer, k, such that InLayer(c, k)
* For all classes, c, d with InLayer(c, k), InLayer(d, l): if c depends on d, k = l + 1
What is a design pattern?
A recurring solution to a problem in a context.
What is the strategy design pattern?
Enables selecting an algorithm at runtime. Instead of implementing a single algorithm directly, code receives run-time instructions as to which in a family of algorithms to use.
- Strategy pattern deals with how an object performs a certain task – it encapsulates an algorithm.
What is the state design pattern?
State design pattern is used to define and manage state of an object, while Strategy pattern is used to define a set of interchangeable algorithm and lets client to choose one of them. So Strategy pattern is a client driven pattern while Object can manage the state itself.
- State pattern deals with what (state or type) an object is (in) – it encapsulates state-dependent behavior
What is the abstract factory design pattern?
provides a way to create families of related objects without imposing their concrete classes, by encapsulating a group of individual factories that have a common theme without specifying their concrete classes. E.g. AbstractFactory() creating ConcreteFactory() creating ProductA() and ProductB()
Problem: Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
Implementation: Define an abstract factory interface, which declares creation methods for different types of objects. Each concrete factory implements this interface to create specific products.