Software Design Flashcards

(31 cards)

1
Q

Software development lifecycle (SDLC)

A

A set of 5 stages that are typically part of creating a software product. They are:

  1. Requirements Elicitation - what needs to be built?
  2. Design - how should it be built?
  3. Implementation - build it!
  4. Testing - does it work correctly?
  5. Maintenance - how can it be improved?
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Software design

A

​In software development design is typically used to refer to the process of converting the requirements of the system to the implementation (i.e. plain english to Java or Pseudocode).

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

How do we design software? (5 steps)

A
  1. Perform domain modeling
  2. Apply good architecture
  3. Determine the appropriate data structures
  4. Apply design patterns where appropriate
  5. Refactor as needed
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Domain modeling

A

An activity that occurs early in the design stage, where the concepts (classes) that are necessary to represent the program/system are identified. In this process, the concepts’ properties, behaviors, and relationships are also identified. It is typically achieved using grammatical parsing.

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

Grammatical parsing

A

An approach in which roles in the design are based on the parts of speech used to specify the system in the English description. Typically, we translate them as:

  • Nouns = classes or attributes
  • Adjectives = subclasses or attributes
  • Verbs = operations or relationships
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How do you determine if a noun should be a class or an attribute of another class?

A

A noun should be a class if:

  • it has multiple attributes and / or operations
  • all attributes / operations are common to all instances of the class

Otherwise, it should likely be an attribute of another class.

For example, in the following requirements, all nouns should be their own class since they each stand on their own (i.e. none of them exist solely to describe another).

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

How do you determine the appropriate class for an operation? (i.e. “where to put the verbs”)

A

Typically in languages like Java the operations are contained in classes that correspond with the subject of the sentence. For example, in the following sentence, the “apply” operation would be implemented in the student class, since the student is the subject of the sentence (as opposed to the program which is the object):
“The student applies to a program.”

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

How do you determine if an adjective should be a subclass or an attribute of another class?

A

An adjective should be a subclass if:

  • different adjectives would imply different or additional behavior or operations
  • different adjectives would imply different attributes

Otherwise, it should be an attribute.

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

Unified modeling language (UML) class diagram

A

UML Is language / notation used for modeling and visualizing software design that has been an industry standard since the late 1990s. A class diagram is one type of UML diagram that visualizes classes, their attributes, their operations, and their relationships with other classes. The following image is an example:

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

What are the 4 main types of class relationships?

A
  1. Is-a relationship: generalization / specialization & realization / actualization
  2. Has-a relationships: aggregation & composition
  3. Uses relationship (aka dependency)
  4. Association

These are represented in UML in the following manner:

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

Has-a relationship

A

​One of the possible relationships between classes, which is also known as a “part of” relationship. There are two types of such a relationship which are: aggregation (denoted by a line ending with an empty diamond-shaped arrowhead), and composition (denoted by a line ending with a filled diamond-shaped arrowhead). These are depicted below:

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

Aggregation

A

A has-a relationship between two classes that indicates that one class is part of the other, but can exist independently on its own.

In Java, this is implemented by using instance variables that refer to other objects in a class. This is expressed in the following example in which a dog can exist independently of a person, but in the class definition of Person, there’s an aggregation relationship between Person and Dog:

public class Dog {
}
public class Person {
 public Dog dog;
}

In UML this is depicted by a solid black line with an empty diamond pointing from the object being had to the object that has it. This is depicted in the following diagram:

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

Composition

A

A has-a relationship between two classes that is a stricter form of aggregation. It indicates that one class is part of the other, but ​cannot​ exist without the class to which it belongs.

In Java, this is implemented by using instance variables that refer to other objects in a class. In addition, the instance variables that are part of the new data type the class defines should be initialized in the constructor since it is dependent on them. The following example of a Person having a Job illustrates this relationship:

public class Job {

private String role;

private double salary;

private int id;
}
public class Person {

private Job job;

public Person( ) {

this. job = new Job( );
job. setSalary(1000);

}

In UML, this relationship is denoted by a line ending with a filled diamond-shaped arrowhead.

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

Is-a relationship

A

One of the possible relationships between classes in object-oriented programming. There are two types of such a relationship which are: generalization, or specialization (denoted by a solid line ending with a triangular arrowhead), and realization (denoted by a dashed line ending with a triangular arrowhead). These are depicted a UML diagram in the following first and examples respectively:

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

Generalization / specialization

A

A relationship between two Objects that indicates that one Object is a specialization of another. For example, a Person is a generalization of Professor and a Professor may have additional attributes/operations.

In Java, this is implemented with inheritance. That is, the more specialized subclass, in this case Professor, extends the more general parent class, Person.

In UML, this is denoted by a solid line ending with a triangular arrowhead. Note that the line originates at the subclass and points to the parent class. Therefore, the UML diagram is drawn as the relationship is decribed in English: “a Professor is a Person.”

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

Realization / actualization

A

A relationship between two Objects that indicates that one Object is an actualization/realization of another. An Object A that is realized by another Object B, is generally an abstract concept, meaning that Object A has no notion of existence without being a specific type of object Object B. For example, savings accounts and checking accounts are both realizations of the abstract concept banking account. That is, there’s no notion of something only being a banking account; it must either be a savings account or a checking account.

In Java, this is implemented by extending an abstract class or implementing an interface.

In UML, this is depicted by a dashed line ending with a triangular arrowhead:

17
Q

Uses relationship (AKA Dependency)

A

One of the possible relationships between classes in object-oriented programming, also known as a uses relationship. It indicates that a class A uses the attributes / operations of another class B, but B is not a part of class A.

In Java, this is implemented by the methods of a class using the data / operations of another class. For example, the beginWork method in an Employee class uses a TimeSheet class to record when someone “clocks in.”

In UML this is denoted by a dashed line. This is depicted in the following example:

18
Q

Association

A

The weakest possible relationship between classes, which is denoted by a solid line in a UML diagram. It indicates that the two classes it connects go together in some way. This is depicted in the following example:

19
Q

How is the following code represented in UML?

A

This is an aggregation relationship, which is depicted as follows:

20
Q

How is the following code represented in UML?

A

This is a realization relationship, which is depicted as follows:

21
Q

How is the following code represented in UML?

A

Given that Mammal and Animal are both abstract classes and cannot be instantiated on their own these are all realization relationships, which are depicted below:

22
Q

How is the following code represented in UML?

A

All of the relationships are aggregation and the multiplicities are as follows:

  • a Film has zero or more Actors
  • a Film has one Director
  • a Director has one favorite Actor

This is depicted in the UML diagram below:

23
Q

How is the following code represented in UML?

A

There is an aggregation, or has a, relationship between Employee and Address, and a dependency, or uses, relationship between Employee and Timesheet. This is depicted in UML as follows:

24
Q

Multiplicity

A

This indicates how many instances of one class A can be related to another class B and vice versa. In UML, this is expressed as followed:

  • N​ denotes a multiplicity of exactly ​N​ objects/instances
  • * denotes a multiplicity of zero or more objects/instances
  • M..N​ denotes a multiplicity with a minimum of ​M​ and a maximum of ​N​ objects

In the following example, this notation signifies that 1 customer can have more than 1 bank account but each bank account can only belong to 1 customer.

25
What are the 3 most important software design principles that influence internal quality?
1. Modularity 2. Functional Independence 3. Abstraction
26
Modularity
A concept in software quality that refers to the idea that each module (or class) is only responsible for a single part of the functionality of the overall system. By splitting up the functionality into separate modules, we make the code easier to read and understand, easier to test and debug, easier to reuse, and most of all, easier to change.
27
Monolith
This refers to a software architecture in which a single piece of code (a single main function for example) is responsible for the functionality of the entire program. This is the opposite of modular architecture and is one of the worst design decisions you can make as it will compromise almost every aspect of internal software quality.
28
Functional independence
The notion that components (classes / modules) should have minimal dependence on other components. By allowing a module to perform its tasks with minimal dependence on other modules, we make it easier to understand, test, and reuse on its own, but most of all, it makes the class easier to change without having to change other modules. Functional independence is achieved by: * Minimizing the complexity of interfaces between modules * Minimizing the control that one module has over another
29
Abstraction
The notion that components (classes) should be able to use other components with minimal knowledge of the details of their implementation. This mostly helps with improving stability, as changes to the internal details of other modules should have no effect on the module using them, since it never depended on those details anyway.
30
Software architecture
The process of dividing a software system into a subsystems that address major parts of functionality. Each subsystem should be able to do its work with minimal dependency on other subsystems and minimal knowledge of their implementation.
31
Three tier architecture (TTA)
An example of software architecture in which the system is split up into three subsystems: 1. ​Data - The bottom tier of TTA, it contains all the code that handles functionality related to storing and retrieving data. It doesn’t interact with the user or do any processing of the data, it just makes it possible for the rest of the program to access whatever data it needs to use. 2. Logic​ - The middle tier of TTA, this is where the program performs calculations, makes decisions, etc. This part of the code doesn’t interact with the user either, and it doesn’t do anything with storing and retrieving data. 3. Presentation - The top tier of TTA and is also known as the user interface tier. This is where all user interaction occurs, no data processing or storage is handled in this tier.