Final Exam Review for ISOM 3210 System Analysis and Design

Willis WAN, Chun Yu | 2018-12-01

This was my revision notes when I prepared for the final exam of ISOM 3210 System Analysis and Design. This is transcribed from my old website so the formatting might be off. The content might not be updated as well.
This is served as a reference only, and I have no intention to update this note.

Exam Coverage

  • Class Diagram
  • Sequence Diagram
  • Behaviour State Machine Diagram

Class Diagram

  • Foundation of Object-Oriented Programming
    • Procedural Programming vs Object-Oriented Programming
    • Objects, Classes, Properties, and Methods
    • The Object-oriented View of a System
    • Principles of OOP
  • Foundation of Relational Database Design
    • Why Relational Database?
    • Four Basic Operations in Database Manipulation
    • Entities and Attributes
    • Relationship
    • Primary Keys and Foreign Keys
    • Problems of Poor Database Design
    • Resolution of Many-To-Many Relationships
    • Normalization

Foundation of Object-Oriented Programming

Procedural Programming vs Object-Oriented Programming

  • Traditional programming languages are considered as procedural because programmers need to specify the steps of commands logically. It focuses on ‘how’ a problem is to be solved.
function cal() {
	var radius, circumference, area;
	
	radius = 5;
	
	circumference = 2 * 3.14 * radius;
	area = 3.14 * radius ^ 2;
	
	console.log("Circumference: " + circumference + " Area: " + area);
	// OUTPUT: Circumference: 31.4 Area: 78.5
}
  • As systems are built with increasing complexity, programmes are becoming harder to maintain. Codes are hard to be re-used as they are written as problem-based context.

    • If I want to re-use any code of the above example, I have to copy all 6 lines of codes and changes all variable names so they won’t duplicated! So difficult to do this without mistakes!
  • Object-oriented Programming (OOP) languages are developed to improve the quality (?), reusability, and maintainability of large programmes.

// Class Definition
class circle {
	// Attributes
	constructor(radius) {
		this.radius = radius;
	}
	// Methods
	get circumference() {
		return this.radius * 2 * 3.14;
	}
	get area() {
		return this.radius * this.radius * 3.14;
	}
}

//Main Programme
let cir_5 = new circle(5);
console.log("Circumference: " + cir_5.circumference + " Area: " + cir_5.area);
// OUTPUT: Circumference: 31.4 Area: 78.5
  • If I want to have another circle with radius of 10, all I need to do is use another variable to create a new object, and copy the last line!

Objects, Classes, Properties, and Methods

  • An object consists of:
    1. some data values that defines the object (radius of a particular circle), and
    2. a set of functions that can be applied to the object itself (calculating the area and circumerence of a particular circle).
  • A class is a general category that defines:
    1. what are the attributes (properties) that the object contains (Every circle has its radius), and
    2. what are the behaviours (methods) that can be applied on the object (We can calculate the area and circumference of all circles).
  • Brain-teaser: Is a class an object?

The Object-Oriented View of a System

  • Whilst designing a system, an object-oriented paradigm suggests that objects (specific instances of a class, or equivalently, instances of an actor) are interacting with one another.
  • Objects are communicated through sending and receiving messages. Upon receiving a message, an object responds with behaviour as determined in the respective class.
    • How do actors interact when a certain event happens? Sequence Diagram

UST Student Example

// Class Definition
class student {
  constructor(name, sid) {
    // Defining the Proprities
    this.Name = name;
    this.Sid = sid;
    this.Gp = 0;
    this.Credit = 0;
    this.CurrentCredit = 0;
  }

  // Defining the Methods
  enrolCourse(credit) {
    if ((this.CurrentCredit + credit) <= 18) {
      this.CurrentCredit += credit;
      console.log("Enrolled to " + credit + " credits.")
      return true;
    } else {
      console.log("Over-loaded!");
      return false;
    }
  }

  endCourse(credit, points) {
    this.CurrentCredit -= credit;
    this.Credit += credit;
    this.Gp += (credit * points);
    console.log("Completed " + credit + " credits.");
    console.log("New GPA: " + (this.Gp / this.Credit));
  }
}
// Main Programme
let Willis = new student("Willis", 20423038);
Willis.enrolCourse(3); 	// OUTPUT: Enrolled to 3 credits.
Willis.enrolCourse(20); // OUTPUT: Over-loaded!
Willis.enrolCourse(13); // OUTPUT: Enrolled to 13 credits.
Willis.endCourse(3, 4.3); 
// OUTPUT: Completed 3 credits.
// OUTPUT: New GPA: 4.3
Willis.endCourse(4, 4.0); 
// OUTPUT: Completed 4 credits.
// OUTPUT: New GPA: 4.128571428571428

Principles of Object-Oriented Programming

  • Although these principles are not tested, they will let us know
    • why can attributes of a class only be accessed through methods of the same class (abstraction through encapsulation);
    • how to model objects that fits to multiple classes (inheritance), and;
    • what happens to behaviours of an object when they belong to multiple classes (polymorphism).

Abstraction through Encapsulation

  • Abstraction, also known as data hiding, means that how a class is implemented, including what attributes a class has, is hidden from the outside world. The way we implement data hiding is known as encapsulation.
    • In this way, important information will not be affected undesirably by the outside world, because the only way to alter these values is through the method of a class.
    • The programmer will therefore has the control on how data is accessed and modified.

Inheritance

  • Inheritance is used to model objects of the same class but possessing different types.

    • For example, there are different types of UST students; some are business students, and some are engineering students. Although they are UST students and shares the same attributes and methods, there are also attributes and methods that are different amongst the two types of students. (e.g., toleratingLowGPA())

    Example of Inheritance

    • By definition, classes at the bottom of the tree (commonly known as child class) must inherit the attributes and methods of the class at the top of the tree (commonly known as parent class).

Polymorphism

  • Polymorphism means “many forms”. Common polymorphism forms include overloading and overriding.
    • Overloading and overriding dictates how classes should behave when the methods share the same name.

Foundation of Relational Database

Why Relational Database?

  • Data of a system must be stored in physical hardware. Database describes the centralized management of data within a certain system/systems.
  • Traditional file-based data management does not work well because data are scattered for different purposes, which leads to numerous problems such as inconsistency, unnecessary duplication, etc.
    • Consider a scenario where the Business School adopts a file-based approach. Without a shared database, each department is responsible for recording students who enrolled to their majors. Suppose each student can enroll to any number of majors. If a student changes information of themselves (e.g., if they change their name), how should this be reflected in a file-based approach?

Four Basic Operations in Database Manipulation

  • SELECT
  • INSERT
  • UPDATE
  • DELETE

Entities and Attributes

  • A relational database describes the relation between data and categorizes them into different tables (known as a relation). Each column of a relation represents an attribute. Each row of a relation represents an entity.
    • An entity is anything that can be distinguished from any other entity. (Simply put, if I put two things in front of you, you can tell them apart because they are unique in nature.)
    • An attribute describes a property of an entity.
      • For example, in a STUDENT relation, entities share attributes such as Student_ID, First_Name, Last_Name, Major, Gender, Birth_Date, etc.
    • This echoes with OOP, in which each class is a relation, and each entity is an object.

STUDENT Relation

Student_IDFirst_NameLast_NameMajorGenderBirth_Date
12345678Chun YuWanBBA(IS)Male1998-01-01

Relationship

  • Associations amongst relations are called relationship.
    • Suppose there are two relations in a database: STUDENT, which records all students in HKUST, and; SCHOOL, which records all four schools in HKUST.
    • Since each student belongs to a school, there is a relationship between STUDENT and SCHOOL.
    • In a class diagram, this is reflected by drawing a line between two classes.

Primary Keys and Foreign Keys

  • Since entities are unique in nature, a primary key is used to uniquely identity each entities.
    • This is the reason why ID is an automatic field when drawing the class diagram.
  • A foreign key is one or more attributes in one relation that matches the primary key of another relation.
    • Suppose the primary key of STUDENT relation is Student_ID and the primary key of the SCHOOL relation is School_ID. Since each student belongs to a school, we should record the information in the STUDENT relation. Therefore, one of the fields in the STUDENT relation is School_ID. In this case, we say that School_ID is the foregin key of the STUDENT relation.

Problems of Poor Database Design

  • Unnecessarily Duplicated Data
  • Inconsistent Modifications
  • Loss of Critical Data
  • Introduction of NULL Value
  • Inconsistent Identifiers

Resolution of Many-To-Many Relationships

Normalization

  • First Normal Form (1NF): Atomic Value, No Repeating Group
  • Second Normal Form (2NF): 1NF Without Partial Functional Dependency
  • Third Normal Form (3NF): 2NF Without Transitive Functional Dependency

Sequence Diagram

Sequence Diagram describes the order of a use case. To be precise, it describes how messages are passed between actors and classes by triggering methods of different classes.

  • Each arrow represents a message (e.g. even with endCourse()). Shows all messages between actors and classes.

Example Sequence Diagram

Behaviour State Machine Diagram

Behvaiour State Machine Diagram describes how state/status of an object change in our system over time.