Detailed design Flashcards

1
Q

What is the 3,1,2 process for solving design problems?

A

Can be used individually, but often work nicely in concert, in the order ③, ①, ②

  1. 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.)
  2. Favor object composition over class inheritance. (Why? Composition-based designs are more flexible)
  3. 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.

  1. 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.
  2. 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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the intensionality/locality thesis?

A

= Guideline to distinguish between architecture, design and implementation.

Architecture | Intensional | Non-local
Design | Intensional | Local
Implementation | Extensional | Local

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

What are the 12 design patterns?

A

Strategy, state, abstract factory, facade, decorator, adapter, builder, state, command, proxy, composite, observer

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

What is detailed design?

A

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.

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

What is system design?

A

The process of defining the architecture, components, interfaces, and other
characteristics of a system or component

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

What is the difference between detailed software design and software architecture?

A

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.

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

Architecture, design, implementation: What is design models?

A

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.

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

Architecture, design, implementation: What is specifications?

A

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

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

Architecture, design, implementation: What is intensionality vs extensionality?

A

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)

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

Architecture, design, implementation: Non-locality

A

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.

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

What is layered architecture?

A

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

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

What is a design pattern?

A

A recurring solution to a problem in a context.

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

What is the strategy design pattern?

A

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.

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

What is the state design pattern?

A

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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the abstract factory design pattern?

A

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.

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

What is the adapter pattern?

A

Also known as wrapper. Allows the interface of an existing class to be used as another interface. It is often used to make existing classes work with others without modifying their source code.

Problem: Make incompatible interfaces work together.

Implementation: Convert the interface of a class into another interface that clients expect. This is achieved by using a wrapper class, called an adapter, that translates requests between the two interfaces.

17
Q

What is the composite pattern?

A

The composite pattern is a partitioning design pattern. The composite pattern describes a group of objects that are treated the same way as a single instance of the same type of object. The intent of a composite is to “compose” objects into tree structures to represent part-whole hierarchies. Implementing the composite pattern lets clients treat individual objects and compositions uniformly.

The Composite Pattern is useful in situations where you need to represent part-whole hierarchies or tree-like structures. It simplifies the client’s code by providing a consistent interface for working with both individual objects and collections of objects. It also allows you to add new components to the hierarchy without affecting the existing code that relies on the component interface.

18
Q

What is the decorator pattern?

A

In object-oriented programming, the decorator pattern is a design pattern that allows behavior to be added to an individual object, dynamically, without affecting the behavior of other objects from the same class.

Problem: Add additional functionality to objects dynamically.

Implementation: Create a decorator class that wraps the original object, providing additional behavior by modifying or extending its methods.

19
Q

What is the factory method pattern?

A

The factory method pattern is a creational pattern that uses factory methods to deal with the problem of creating objects without having to specify the exact class of the object that will be created. This is done by creating objects by calling a factory method—either specified in an interface and implemented by child classes, or implemented in a base class and optionally overridden by derived classes—rather than by calling a constructor.

The Factory Method pattern suggests that you replace direct object construction calls (using the new operator) with calls to a special factory method.

Problem: Create objects without specifying the exact class of object that will be created.

Implementation: Define an interface for creating objects, and let subclasses decide which class to instantiate.

20
Q

What is the observer pattern?

A

The observer pattern is a software design pattern in which an object, named the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods.

Problem: Establish a one-to-many dependency between objects, where changes in one object trigger updates in dependent objects.

Implementation: Define a subject (observable) and multiple observers. The subject maintains a list of observers and notifies them when its state changes.

21
Q

What is the template method pattern?

A

Problem: Define the skeleton of an algorithm in a method, allowing subclasses to provide certain steps of the algorithm without changing its structure.
Implementation: Define an abstract base class that provides a template method containing the algorithm’s steps. Subclasses override specific steps to customize the behavior.

22
Q

What is the facade pattern?

A

Analogous to a facade in architecture, a facade is an object that serves as a front-facing interface masking more complex underlying or structural code.

23
Q

What is the builder pattern?

A

Problem: Simplify the creation of complex objects by providing a step-by-step approach.
Implementation: Separate the construction of an object from its representation, allowing the same construction process to create various representations.

24
Q

What is the command pattern?

A

The Command Pattern is a behavioral design pattern that addresses the problem of decoupling the sender of a request from the object that performs the action. It encapsulates a request as an object, thereby allowing you to parameterize clients with different requests, queue or log requests, and support undoable operations.

25
Q

What is computational models?

A

computational models for reasoning about algorithms

26
Q

What is design models?

A

abstractions for reasoning about certain structural aspects of software