Software Design Flashcards
(31 cards)
Software development lifecycle (SDLC)
A set of 5 stages that are typically part of creating a software product. They are:
- Requirements Elicitation - what needs to be built?
- Design - how should it be built?
- Implementation - build it!
- Testing - does it work correctly?
- Maintenance - how can it be improved?
Software design
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 do we design software? (5 steps)
- Perform domain modeling
- Apply good architecture
- Determine the appropriate data structures
- Apply design patterns where appropriate
- Refactor as needed
Domain modeling
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.
Grammatical parsing
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 do you determine if a noun should be a class or an attribute of another class?
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 do you determine the appropriate class for an operation? (i.e. “where to put the verbs”)
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 do you determine if an adjective should be a subclass or an attribute of another class?
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.
Unified modeling language (UML) class diagram
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:

What are the 4 main types of class relationships?
- Is-a relationship: generalization / specialization & realization / actualization
- Has-a relationships: aggregation & composition
- Uses relationship (aka dependency)
- Association
These are represented in UML in the following manner:

Has-a relationship
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:

Aggregation
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:

Composition
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.
Is-a relationship
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:

Generalization / specialization
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.”

Realization / actualization
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:

Uses relationship (AKA Dependency)
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:

Association
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:

How is the following code represented in UML?

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

How is the following code represented in UML?

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

How is the following code represented in UML?

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:

How is the following code represented in UML?

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:

How is the following code represented in UML?

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:

Multiplicity
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.
