Presentation is loading. Please wait.

Presentation is loading. Please wait.

Class Diagrams Tutorial.

Similar presentations


Presentation on theme: "Class Diagrams Tutorial."— Presentation transcript:

1 Class Diagrams Tutorial

2 Conceptual class diagram-Online Bookstore
An Informal Description "The system is an online, web-based bookstore. The bookstore sells books, music CDs, and software. Typically, a customer first logs on to the system, entering a customer ID and password. The customer can then browse for items or search by keyword(title, Author , Publisher, ISBN). The customer puts some of the items into a "shopping cart" which keeps track of the desired items. When the customer is done shopping, he/she confirms the order, shipping address, and billing address. The bookstore system then issues a shipping order, bills the customer, and issues an electronic receipt. At the end of the transaction, the customer logs off."

3 Online Bookstore A Scenario User logs on.
System displays welcome message and requests customer ID and password. User enters customer ID and password. System validates the ID and password. User searches for a items by browsing or keyword search System displays information about the title. User selects a title to buy System adds items to the customer's shopping cart [Repeat 5-8 until done] User is done with shopping System displays shopping cart, shipping address, and billing address User confirms order and payment method. System processes order, notifies warehouse for shipping, and issues an electronic receipt. User logs

4 Identify the classes Look for important nouns: Objects, people, organizations, places, events, concepts. From the given scenario OnLineBookstore, Customer, Book, MusicCD, Software, order, shoppingCart are the classes

5 Class Attributes Analyze the requirements to find the attributes of each class A Customer has a name, customerID, password, shippingAddress, and billingAddress. An Address has a street, city, state, country, and postalCode.

6 Relationships Analyze the requirements to find relationships between classes. Draw relationships as lines between class boxes. Annotate the relationships: How many OrderItems for each Order are possible? Use symbols to indicate the kind of relationship: Generic, aggregation (has-a or owns-a), inheritance (is-a). For generic relationships, use an arrowhead to indicate whether the relationship is navigable: Does the source object know about the destination object? After identifying candidate classes, see if there are any commonalities between them that might be an IS-A relationship. It may make sense to factor the common parts into a super class, and create an inheritance relationship:

7 Finding Relationships

8 Class diagram

9 Conceptual class diagram-Programming Language
Based on the following description of part of the syntax of a programming language, construct a class diagram showing the structure of programs written in the language and show the types of associations between the classes. - A module consists of a collection of features. A feature can either be a variable, a routine or a nested module. Routines consist of a declaration part and a statement part. Features local to the routine can be declared in the declaration part, and the statement part consists of a non-empty sequence of statements. Statements can be loops, conditionals or assignments, and each assignment contains a reference to the variable which is being assigned to.

10 Identify the classes Feature Variable Routine Module DeclarationPart
Statement Part Statement Loop Conditional Assignment

11 Solution Class diagram

12 Hospital Information System
Informal Description "The system is a hospital information system. A hospital has doctors and patients. Each patient is assigned to one doctor, but a doctor can have any number of patients. Patients check in to the hospital and assigned a doctor if they don't already have one. While in the hospital, doctors record various observations about each patient at various times. Examples of observations are blood pressure and temperature. The hospital keeps track of all the observations for a given patient until they check out of the hospital."

13 Scenario Patient checks in to hospital.
Hospital assigns doctor to the patient. The doctor records a blood pressure measurement for the patient. The doctor records a temperature for the patient. The doctor prescribes medicine for the patient's condition. The patient checks out of the hospital.


Download ppt "Class Diagrams Tutorial."

Similar presentations


Ads by Google