Presentation is loading. Please wait.

Presentation is loading. Please wait.

Fall 2002 SJSU -- CmpE Enterprise & Application Frameworks Dr. M.E. Fayad, Professor Computer Engineering Department – RM# College of Engineering San José.

Similar presentations


Presentation on theme: "Fall 2002 SJSU -- CmpE Enterprise & Application Frameworks Dr. M.E. Fayad, Professor Computer Engineering Department – RM# College of Engineering San José."— Presentation transcript:

1 Fall 2002 SJSU -- CmpE Enterprise & Application Frameworks Dr. M.E. Fayad, Professor Computer Engineering Department – RM# College of Engineering San José State University One Washington Square San José, CA 95192-0180 URL: http://www.cmpe.sjsu.edu/~fayad

2 L4-S2OO Concepts-2 Fall 2002 SJSU -- CmpE M.E. Fayad 2 Lesson 4: Object-Oriented Concepts-2

3 L4-S3OO Concepts-2 Fall 2002 SJSU -- CmpE M.E. Fayad Lesson Objectives 3 Understand UML notation Discuss UML- objects Explore UML- classes Understand UML interfaces Explore UML associations Understand CRC cards

4 L4-S4OO Concepts-2 Fall 2002 SJSU -- CmpE M.E. Fayad  Classes should make sense in the problem domain.  Good classes classify the objects which need to be modeled in the system.  Classes often correspond to NOUNS.  Avoid redundant or irrelevant classes which add no value in the problem domain.  Remove classes which have no attributes. 4 Selecting Good Classes

5 L4-S5OO Concepts-2 Fall 2002 SJSU -- CmpE M.E. Fayad After initial pass, discard classes which are:  Redundant  Irrelevant to the problem domain  Vague  Attributes  If class name has no attributes of its own, it is probably an attribute. 5 Elimination of Inappropriate Classes

6 L4-S6OO Concepts-2 Fall 2002 SJSU -- CmpE M.E. Fayad The Problem Statement: A simple cash register has a display, an electronic wire with a plug, and a numeric keypad which has keys for subtotal, tax, and total. This cash storage device has a total key which triggers the release on the drawer. The numeric buttons simply place a number on the display screen, the subtotal displays the current total, the tax key computes the tax, and the total key adds the subtotal to the tax. Identify all the classes in this problem statement Use the class elimination rules to eliminate the unnecessary classes. 6 Example: Simple Cash Register

7 L4-S7OO Concepts-2 Fall 2002 SJSU -- CmpE M.E. Fayad We are going to use nouns to find classes Nouns (initial) RegisterDisplayWire PlugKeypad Keys DevicesReleaseDrawer ButtonsScreenNumber TotalTax Nouns (General Knowledge) 0-9 keys Money Subtotal Key Tax Key Total Key 7 Classes in Initial Phase

8 L4-S8OO Concepts-2 Fall 2002 SJSU -- CmpE M.E. Fayad 8 Eliminating Unnecessary Nouns Register Display Wire---> Irrelevant Plug---> Irrelevant Keypad Keys Devices---> Vague Release---> Irrelevant Drawer Buttons---> Redundant Screen---> Redundant Number---> Attribute Total ---> Attribute Tax---> Attribute 0-9 Key Value---> Attribute Money Subtotal Key Tax Key Total Key

9 L4-S9OO Concepts-2 Fall 2002 SJSU -- CmpE M.E. Fayad 9 Class in UML Circle radius {radius>0} centerpoint: Point = (10, 10) display () remove () setPosition (pos: Point) setRadius (newRadius) Class name Attribute name Attribute type Operations Constraint Initial value Parameters (name: type= initial value

10 L4-S10OO Concepts-2 Fall 2002 SJSU -- CmpE M.E. Fayad 10 Objects in UML aCircle: Circle radius = 21 centerpoint = (10, 10) Instance name Attribute names Class name Attribute values Classes and objects are units composed of attributes, Operations, and constraints.

11 L4-S11OO Concepts-2 Fall 2002 SJSU -- CmpE M.E. Fayad 11 Corresponding Code in Simplified Java Class Circle { int radius; Point centerpoint; public void setRadius (int newRadius) { if (newRadius > 0)// constraint { radius = newRadius; ….. } public void setPosition (Point pos) { … } public void display ( ) { … } public void remove ( ) { … }

12 L4-S12OO Concepts-2 Fall 2002 SJSU -- CmpE M.E. Fayad 12 System Responsibilities & Collaborations Define Responsibilities – What are the goals of the system – What must objects know to meet goals – What steps must each object accomplish Determine Collaborations – Decompose responsibilities into interactions among objects – Define clients and servers – Where should knowledge be held

13 L4-S13OO Concepts-2 Fall 2002 SJSU -- CmpE M.E. Fayad 13 CRC Cards General – Each class is described on a separate 3X5 or 4X6 card The cards are known as CRC cards; they have 3 sections: – Class – Responsibilities – Collaborations

14 L4-S14OO Concepts-2 Fall 2002 SJSU -- CmpE M.E. Fayad 14 More on CRC Cards Class Name (Role) Responsibility Collaboration Client Server Specify One, Unique Responsibility, & WithinCollaborators Interfaces or services Contextprovided by named class

15 L4-S15OO Concepts-2 Fall 2002 SJSU -- CmpE M.E. Fayad 15 More on CRC Cards ATM (Automatic Teller) Responsibility Collaboration Access & modify account balance Account (Checking) Balance Inquiry Deposit Transaction Funds Transfer Withdrawal Transaction Class name CollaboratorsRoles Client Server

16 L4-S16OO Concepts-2 Fall 2002 SJSU -- CmpE M.E. Fayad What are the good, bad, and ugly about CRC cards? Propose a process of how to use the CRC cards T/F –CRC stands for Common Responsible Class –According to UML, Class is composed of attributes and collaborators. Define: –Associations, Instance, CRC, responsibilities, and collaborations 16 Discussion Questions


Download ppt "Fall 2002 SJSU -- CmpE Enterprise & Application Frameworks Dr. M.E. Fayad, Professor Computer Engineering Department – RM# College of Engineering San José."

Similar presentations


Ads by Google