Скачать презентацию Software Engineering Zhang Shuang Software College Northeastern University Скачать презентацию Software Engineering Zhang Shuang Software College Northeastern University

fb69d9ca3a842a9cc52e35f879be4013.ppt

  • Количество слайдов: 20

Software Engineering Zhang Shuang Software College Northeastern University Software Engineering Zhang Shuang Software College Northeastern University

Object-Oriented Analysis ---- Class Modeling Object-Oriented Analysis ---- Class Modeling

Class Modeling § What is a class diagram? Ø A class diagram shows the Class Modeling § What is a class diagram? Ø A class diagram shows the existence of classes and their relationships in the logical design of a system. A class diagram may represent all or part of the class structure of a system. Ø Class diagrams show the static structure of the model, in particular, the things that exist such as classes, their internal structure, and their relationships to other classes. Ø It is the static view of a system, primarily supports the functional requirements of a system.

Class Modeling u Extract classes and their attributes u Represent them using an entity-relationship-like Class Modeling u Extract classes and their attributes u Represent them using an entity-relationship-like diagram u Deduce classes from use cases

Two Approaches to Class Modeling v Noun extraction Ø Always works v CRC, Class-Responsibility-Collaboration Two Approaches to Class Modeling v Noun extraction Ø Always works v CRC, Class-Responsibility-Collaboration Ø Need to have domain expertise Ø For testing class diagram

Noun Extraction v Step 1. Concise Problem Definition Ø Define product briefly and concisely Noun Extraction v Step 1. Concise Problem Definition Ø Define product briefly and concisely Buttons in elevators and on the floors control movement of n elevators in a building with m floors. Buttons illuminate when pressed to request the elevator to stop at a specific floor; illumination is canceled when the request has been satisfied. When an elevator has no requests, it remains at its current floor with its doors closed.

Noun Extraction v Step 2. Formalize the Strategy Ø Identify nouns in informal strategy. Noun Extraction v Step 2. Formalize the Strategy Ø Identify nouns in informal strategy. Use nouns as candidate classes. v Nouns Ø button, elevator, floor, movement, building, illumination, door

Noun Extraction Ø movement, illumination are abstract nouns exclude (may become attributes) — Ø Noun Extraction Ø movement, illumination are abstract nouns exclude (may become attributes) — Ø floor, building, door are outside problem boundary exclude — Ø Candidate classes: Elevator and Button Ø Subclasses: Elevator. Button and Floor. Button

First Iteration of Class Diagram Ø Buttons do not communicate directly with elevators Ø First Iteration of Class Diagram Ø Buttons do not communicate directly with elevators Ø We need an additional class: Elevator. Controller

Second Iteration of Class Diagram Second Iteration of Class Diagram

Case 1. University System Case 1. University System

Case 2. Bank System v A bank system has customers who open account. A Case 2. Bank System v A bank system has customers who open account. A customer can hold accounts in a bank. He can deposit funds to accounts, can withdraw funds from accounts, and can also transfer funds from an account to another. A customer can check balance of his own accounts, and transaction records including depositing, withdrawing and transferring.

Case 3. Online Shop Case 3. Online Shop

Class Modeling u Is there a better way to organize class diagrams? u Package Class Modeling u Is there a better way to organize class diagrams? u Package Ø A general purpose mechanism for organizing elements into groups. Ø A model element that can contain other model elements. Ø Rules ü Classes with aggregation or composition belong to the same package ü Classes with a lot of association belong to the same package

Class Modeling u Package can include other packages Ø e. g. : Java class Class Modeling u Package can include other packages Ø e. g. : Java class library ü ü Package io is in package java. ü u Class File is in package io, The full name of File is java. io. File Avoid too deep nested package Ø Normally 2~3 layers

Class Modeling Class Modeling

CRC Cards u CRC Class-Responsibility-Collaboration CRC Cards u CRC Class-Responsibility-Collaboration

CRC Cards u Used since 1989 for OOA u For each class, fill in CRC Cards u Used since 1989 for OOA u For each class, fill in card showing Ø Name of class Ø Functionality (responsibility) Ø List of classes it invokes (collaboration) Ø Now automated (CASE tool component)

CRC Cards u Strength Ø Powerful tool for highlighting missing or incorrect items u CRC Cards u Strength Ø Powerful tool for highlighting missing or incorrect items u Weakness Ø Domain expertise is needed