Software Design

Table of Contents

Structure modeling with UML

Class

a construction plan for a set of similar objects of a system

UML Class Diagram

Attribute syntax

UML Attribute Syntax

Visibility: who is permitted to access the attribute

/ means that attribute value is derived from other attributes

Type:

UML Data Types

Multiplicity: number of values an attribute may contain (as [min..max], max can be * meaning no limit)

= Default: the default value that’s used if the user doesn’t explicitly set a value

properties:

Operation syntax

UML operation syntax

Similar to attributes.

parameter:

UML operation parameter notation

type: type of return value

Class variable and class operation

Class variable (static): defined only once per class, shared by all instances

Class operation (static): can be used without creating an instance

To distinguish class variables/operations, underline them.

Relationships

Binary association

Connects instances of two classes with one another.

UML Class Binary association

Properties:

in Java:

class Professor {...}

class Student {
    public Professor[] lecturer;
}

n-ary association

More than two objects involved in the relationship, no navigation directions.

UML Class Ternary Association

Association class

Assign attributes to relationship between classes instead of to a class.

UML Class Association class

Needed for n:m associations.

Association class vs regular class:

UML Class Association vs regular

Can be unique or non-unique.

Aggregation

Shows that class is part of another class.

Properties:

Shared aggregation

expresses weak belonging of the parts to a whole (parts also exist independently of the whole). one element can be part of multiple other elements at the same time.

Example:

UML Class shared aggregation example

Composition

existence dependency between composite object and its parts. one part can be contained in max one composite object at a point in time. if the composite object is deleted, so are its parts.

A Tire can exist without a Car. A Tire belongs to max one Car:

UML Class composition example

Generalization

stuff from a superclass is passed to its subclass (attributes, operations, associations, aggregations)

every instance of a subclass is simultaneously an indirect instance of the superclass. subclass inherits all characteristics except private ones. generalizations are transitive. a class may have multiple superclasses/subclasses.

UML Class generalisation

abstract class ensures that there are no direct instances of the superclass.

UML Class abstract

Creating a class diagram

nouns often indicate classes. adjectives indicate attribute values. verbs indicate operations.

in general, tend towards having deep classes. push complexity as low as possible in the class diagram hierarchy.

focus on:

generalization: “there is difference between research and administrative employees. some research associates hold courses, so they are lecturers.”

UML Natural text generalization

composition: “a university consists of multiple faculties which are composed of various institutes.”

UML Natural text composition

binary association: “each faculty is led by a dean, who is an employee of the university”

UML Natural text binary association

shared aggregation: “research associates are assigned to at least one institute”

UML Natural text shared aggregation

association class: “research associates can be involved in projects for a certain number of hours”

UML Natural text association class

generalization: “some research associates hold courses. then they are called lecturers.”

UML Natural text inheritance