Final Material - System Design Flashcards

1
Q

What is the difference between architectural design and component design?

A
Architectural design is an abstract version of the system that identifies the software as a system with many components interacting with each other
Component design is more detailed toward modules and implementations. Defines the logical structure of each module and interfaces to communicate with other modules
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is an architectural pattern?

A

A means of representing, sharing, and reusing knowledge. A stylized description of good design practice that has been tried and tested in different environments

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

What is the model view controller architectural pattern?

A

A model that separates presentation and interaction from system data.
The model component manages system data and operations of the data
The view component defines and manages how data is presented to the user
The controller component manages user interaction and passes interactions to the view and the model

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

When should you use model-view-controller architectural pattern

A

When there are multiple ways to view and interact with the data
When the future requirements for interaction and presentation of data are unknown

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

What are the advantages and disadvantages of model view controller architectural pattern?

A

Advantages: allows data to change independently of representation and vice-versa, supports presentation of the same data in different way with changes made in one representation shown in all
Disadvantage: Involves additional code and complexity when data model and interactions are simple

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

What is the layered architecture pattern?

A

Organizes the system into layers with related functionality for each layer

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

When should you use the layered architectural pattern?

A

When building new facilities on existing systems
When development is spread across several teams with each team responsible for a layer
When there is a requirement for multi-level security

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

What are the advantages and disadvantages of the layered architectural pattern?

A

Advantages: allows replacement of entire layers as long as the interface is maintained
Disadvantages: Providing clean separation is difficult and a high-level layer may need to interact with layers not just directly below it, performance can be a problem because of multiple levels of interpretation of a service request

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

What is the client-server architectural pattern?

A

Functionality of the system is organized into services with each service delivered from a different server

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

When should you use the client-server architectural model?

A

When data in a shared database needs to be accessed from a range of locations

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

What are the advantages and disadvantages of client-server architectural pattern?

A

Advantages: Servers can be distributed across a network, general functionality can be available to all clients and does not need to be implemented by all services
Disadvantages: Each service is a single point of failure, performance is unpredictable because it depends on the network and the system

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

What is the pipe-filter architectural pattern?

A

Processing of data is organized so each processing component is discrete and carries out one type of data transformation

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

When should you use pipe-filter architectural pattern?

A

In data processing applications where inputs are processed at separate stages to generate related outputs

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

What are the advantages and disadvantages of pipe-filter architectural pattern?

A

Advantages: workflow style matches the structure of business processes, evolution by adding transformations is straightforward
Disadvantages: format for data transfer needs to be agreed upon by communicating transformations

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

What is coupling?

A

Measures system complexity by focusing on complexity between a module and other modules. Loosley coupled modules make it easy to connect to other modules with well-defined interfaces

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

What is degree with respect to coupling?

A

The number of connections between the module and other which should be small for loose coupling

17
Q

What is ease with respect to coupling?

A

How obvious connections are between modules and others. Connections should be easy to make without needing to understand the implementation of other modules

18
Q

What is flexibility with respect to coupling?

A

Indicates how interchangeable other modules are for the module. They should be easily replaceable for something better in the future

19
Q

What are the signs that a system is tightly coupled?

A
Module connects to other modules through many interfaces
Corresponding modules to a single module are hard to find
Specific modules connected to a module cannot be interchanged
20
Q

What is cohesion?

A

Represents the clarity of responsibilities of a module to determine the complexity of the module

21
Q

How can you tell if a module has low cohesion?

A

Its purpose is not clear
It encapsulates more than one purpose
An encapsulation must be broken to understand a method

22
Q

What are the 5 SOLID design principles?

A
Single Responsibility Principle
Open-Closed Principle
Liskov Substitution Principle
Interface Segregation Principle
Dependency Inversion Principle
23
Q

What is the Single Responsibility SOLID design principle?

A

A class should do one thing and only have one reason to change

24
Q

What is the Open-Closed SOLID design principle?

A

Classes should be open for extension but closed to modification. We should be able to add new functionality without changing existing class code

25
Q

What is the Liskov Substitution SOLID design principle?

A

Subclasses should be substitutable for base classes as a child class extends behaviour but never narrows it down

26
Q

What is the Interface Segregation SOLID design principle?

A

Many client-specific interfaces are better than one general purpose interface as clients should not be forced to implement functions they don’t need

27
Q

What is the Dependency Inversion SOLID design princple?

A

High level modules for business logic should not depend on low level modules for utility features. Both modules should depend on an abstraction that couples the modules

28
Q

What are some important rules about naming variables, functions, and classes

A
  1. Use nouns for objections, variables, classes, properties, and parameters
  2. Use verbs for methods and functions
  3. Use a standard naming convention like snake case or camel case
  4. Use names the reveal the intention of the subject
  5. Use pronounceable names for readability
  6. Use searchable names
  7. Avoid encodings
  8. Don’t add unwarranted context
29
Q

What are some important rules about functions to keep code clean?

A
  1. Functions should be able to fit on a single screen, no more than 10 lines
  2. Functions should do one thing, do it well, and do it only
  3. Allow one level of abstraction per function
  4. Stay away from switch statements as they do more than one thing
  5. Ideal number of arguments is 0, the less the better
  6. Avoid changing parameters inside a function
  7. A parameter should not be boolean
30
Q

What are some important rules about comments to keep code clean?

A
  1. Keep comments updated with the code it references
  2. Comments do not make up for bad code
  3. Examples of good comments are legal comments, informative comments, those that explain intent, warn of consequences, are TODO comments, and amplify importance
  4. Examples of bad comments are those that are redundant, create visual noise, are journal comments, and are commented out code
31
Q

Why is it preferred to throw an exception rather than return an error code

A

When you use an exception you know your code can handle faults, which faults it can handle

32
Q

What are the rules for nulls in clean coding?

A

Don’t return null from a function so your program doesn’t need to follow an alternate flow based on return value
Don’t pass nulls to functions so the function doesn’t have to handle alternate flows

33
Q

What order should the code in a class be organized in?

A
  1. Public static constants
  2. Private static variables
  3. Private instance variables
  4. Public functions
  5. Private utilities called by a public function right after
34
Q

How can we measure class cohesion?

A

Classes should have a small number of instance variables and each method should manipulate one or more of the variables. The more variables it manipulates, the more cohesive it is to its class