SOFTWARE ENGINEERING

Requirements Modeling

Contents covered in last lecture

  • System modeling

  • Existing and planned system models

  • Unified Modeling Language (UML)

    • UML diagram types

  • Context models

    • Example: context model of the MHC-PMS

    • Process perspective

  • Activity Diagram

    • Notations

    • Examples

    • Swimlane Diagram

  • Interaction models

    • Sequence diagrams

    • Representing Objects

    • Message between Objects

    • Selection and Loop

    • Examples

Contents that will be covered in this lecture

  • Structural models

  • Class diagrams

    • Classes

    • Relationship

    • Dependency Relationships

    • Generalization Relationships

    • Association Relationships

    • Examples

Structural Models

  • Definition: Structural models of software display the organization of a system in terms of the components that make up that system and their relationships.

  • Types of Structural Models:

    • Static Models: Show the structure of the system design.

    • Dynamic Models: Show the organization of the system when it is executing.

  • Purpose: Creation of structural models occurs during discussion and design of the system architecture.

Class Diagrams

  • Definition: Class diagrams are utilized in developing an object-oriented system model that depicts the classes in a system and the relationships (associations) between these classes.

  • Object Class: An object class serves as a general definition of one kind of system object.

  • Association: A connection between classes indicating a relationship.

  • Real-world Representation: During initial stages of software engineering, objects symbolize real-world entities such as a patient, prescription, or doctor.

Classes

  • Class Definition: A class describes a set of objects sharing the same attributes, operations, relationships, and semantics.

    • Instances: Each object is an instance of one class; objects cannot belong to multiple classes.

    • Structure and Behavior: All objects of a class share identical structure (attributes) and behavior (methods) but differ in attribute data.

  • **Example of Attributes:

    • Person

    • name: String

    • address: Address

    • birthdate: Date

    • ssn: Id

    • methods: eat, sleep, work, play

Relationships in UML

  • Definition: Object interconnections (both logical and physical) modeled as relationships.

  • Types of Relationships:

    1. Dependency

    2. Generalization

    3. Association

Dependency Relationships

  • Example:

    • Class: CourseSchedule

    • Method: add(c: Course)

    • Method: remove(c: Course)

  • Explanation: A dependency implies a semantic relationship between two or more elements. For instance, CourseSchedule depends on Course since it's referenced in both methods add and remove.

Generalization Relationships

  • Definition: A generalization connects a subclass to its superclass, indicating an inheritance of attributes and behavior from the superclass.

  • Specialization: The subclass is a specialized version of the more general superclass.

  • Terminology: This relationship is informally referred to as an "Is A" relationship.

  • Example:

    • Person

    • Subclasses: Student, TeachingAssistant, Employee

Association Relationships

  • Definition: Association denotes a link between two classes that indicates they communicate with each other.

  • Multiplicity Example:

    • Notation: Student 1..* Instructor

    • Interpretation: A Student has one or more Instructors.

  • Aggregation and Composition: Special associations that model objects containing other objects, indicating a HAS-A relationship:

    • Aggregation: Child can exist independently of the parent.

    • Example: Class (parent) and Student (child); deleting Class does not affect Students.

    • Denoted by a hollow-diamond adornment on the association.

    • Composition: Child cannot exist independently of the parent.

    • Example: House (parent) and Room (child); rooms cannot exist separately from a house.

    • Denoted by a filled-diamond adornment on the association.

Aggregation and Composition Examples

  • Aggregation Example:

    • Car has Engine, Transmission; deleting Car does not eliminate Engine and Transmission.

  • Composition Example:

    • House has Rooms; removing House results in the removal of Rooms as well.

Example Diagrams

Example: School Diagram

  • Entities & Relationships:

    • School offers Department

    • 1..1 Departments

    • 1..* Students attends

    • 1..* Subjects

    • Instructor teaches

Example: Order Processing Class Diagram

  • Attributes:

    • Order (date: date)

    • Customer (name: String, address: String, status: String)

    • OrderDetail (quantity: integer, taxStatus: String)

  • Operations:

    • +calcSubTotal()

    • +calcTax()

    • +calcWeight()

    • +calcTotal()

Example: Bank Transactions Diagram

  • Entities:

    • Customer (attributes: name, address, dob, card number)

    • Bank (attributes: code, address)

    • ATM (attributes: location, managed by)

  • Relationships:

    • Account manages ATM Transactions, Current Account, Savings Account

Example: Online Shopping System Diagram

  • **Roles and Relationships:

    • Admin manages Products, Customer views and buys products, Payments handled, and Cart functionalities.

  • Key Attributes:

    • Payment (CustomerId, Card Type, CardNo)

    • Products (Id, Name, Group, Subgroup)

    • Cart (Id, Number of Products)

  • Operations:

    • Admin can View, Add, Delete, Modify Products, manage Shipment and Delivery

    • Customer can buy products, view products, make payment, add or delete from cart.