04class
Upcoming SlideShare
Loading in...5
×
 

04class

on

  • 739 views

 

Statistics

Views

Total Views
739
Views on SlideShare
739
Embed Views
0

Actions

Likes
0
Downloads
30
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • To create a class using the Browser Click right on the Logical View package (or any user defined package) to make the pop up menu visible. Select the New:Class menu command. This will add a class called NewClass to the Browser. While the new class is still selected, enter its name. As classes are discovered, they are typically added to the Browser.
  • To use namespaces Click right to select the owning package and make the pop up menu visible. Select the New:Class menu command. This will add a class called NewClass to the Browser. While the new class is still selected, enter its name. CAUTION: Although classes may be created on a class diagram, namespace support is only available for classes created used the Browser. Rational Rose 98 i has namespace support. This means that an actor and a class can have the same name or two classes can have the same name as long as they are in different packages.
  • To enter documentation using the Documentation Window Click to select the class in the Browser. Enter the documentation for the class in the Documentation Window. To enter documentation using the Class Specification Click right on the class in the Browser to make the pop up menu visible. Select the Open Specification menu command. Select the General tab. Enter the documentation in the Documentation field. Click the OK button to close the Class Specification. Documentation for a class may be added using the Class Specification or the Documentation Window.
  • To create a stereotype for a class Click right on the class in the Browser to make the pop up menu visible. Select the Open Specification menu command. Enter the stereotype in the Stereotype field. OR Select the arrow in the Stereotype field to make the drop down menu visible and select the desired stereotype. Click the OK button to close the Class Specification.
  • To create an attribute using the Class Specification Click right on the class in the Browser to make the pop up menu visible. Select the Open Specification menu command. Select the Attributes tab. Click right to make the pop up menu visible. Select the Insert menu command. This will add an attribute called name. While the new attribute is still selected, enter its name. Attributes may be created and deleted using the Class Specification.
  • To create an operation using the Class Specification Click right on the class in the Browser to make the pop up menu visible. Select the Open Specification menu command. Select the Operations tab. Click right to make the pop up menu visible. Select the Insert menu command. This will add an operation called opname. While the new operation is still selected, enter its name. Operations may be created and deleted using the Class Specification.
  • To create a new attribute or operation using the Browser Click right on the class in the Browser to make the pop up menu visible. Select the New:Attribute or New:Operation menu command to add a new attribute or operation to the Browser. While the new attribute or operation is still selected, enter its name. To move an attribute or operation using the Browser Click to select the attribute or operation in the Browser. Drag the attribute or operation to its new class. To copy an attribute or operation using the Browser Depress the CTRL key and click to select the attribute or operation in the Browser. Drag the attribute or operation to the class that needs the copy. To delete an attribute or operation using the Browser Click right on the operation in the Browser to make the pop up menu visible. Select the Delete menu command. Attributes and operations may be created, deleted, copied and moved using the Browser.
  • To set attribute export control Click right on the attribute in the Browser to make the pop up menu visible. Select the Open Specification menu command. Select the desired radio button in the Export Control field. Click the OK button to close the Specification Note: This is the export control for the accessor methods, not for the attribute itself. To view the export control as an icon Select the Tools:Options menu command to make the Options window visible. Select the Notation tab. Select the Visibility as Icons checkbox. Click the OK button to close the Options window. Attribute export control is set using the Attribute Specification. Point out that this is the export control for the get/set methods for the attribute.
  • To set operation export control Click right on the operation in the Browser to make the pop up menu visible. Select the Open Specification menu command. Select the desired radio button in the Export Control field. Click the OK button to close the Specification. To view the export control as an icon Select the Tools:Options menu command to make the Options window visible. Select the Notation tab. Select the Visibility as Icons checkbox. Click the OK button to close the Options window. Operation export control is set using the Operation Specification.
  • To create a package Click right on the “owning” package to make the pop up menu visible. Select the New:Package menu command. This will add a package called NewPackage to the Browser. While the new package is still selected, enter its name. Classes may be grouped into packages to facilitate model management and team development. Explain that packages can contain other packages.
  • To relocate a class to a different package Click to select the class in the Browser. Drag the class to the new package. As packages are created, classes are moved to the packages.
  • To open the Main Class Diagram Click the + next to the Logical View package in the Browser to expand the package. Click right on the class diagram called Main to make the pop up menu visible. Select the Open menu command.
  • To add a package to a class diagram Click to select the package in the Browser. Drag the package onto the diagram. The Main class diagram typically shows the architecture of the system. It usually contains only packages.
  • To create a Main class diagram for a package Double click on the package on the Main class diagram. OR Click right on the package in the Browser to make the pop up menu visible. Select the New:Package menu command. This will add a package called NewPackage to the Browser. While the new package is still selected, enter the name Main. To add a class to a class diagram Click to select the class in the Browser. Drag the class onto the diagram. OR Select the Query:Add Classes menu command to make the Add Classes menu visible. Scroll up or down in the packages field to the package containing the classes you want to add to the diagram. Click to select the classes to add. Click the >>>> button to add the classes Click the OK button to close the Add Classes menu. Each package typically contains its own main class diagram. This diagram typically contains the public classes of the package.
  • To create a new class on a class diagram Click to select the class icon on the toolbar. Click on the diagram to place the class. While the new class is still selected, enter its name. NOTE: Rose will add the class to the package that “owns” the class diagram. The class will automatically be added to the Browser. A new class may be created using a class diagram. The class will be “ owned” by the package that “owns” the class diagram.
  • To make the Class Name Completion pop menu available Select the Tools:Options menu command to make the Options window visible. Select the Diagram tab. Select the Class Name Completion checkbox. Click the OK button to close the Options window. The class name completion pop up menu may be used to name classes created using a class diagram.
  • To create an attribute on a class diagram Click right on the class on the diagram to make the popup menu visible. Select the New Attribute menu command. This will add an attribute called name to the class. While the new attribute is still visible, enter its name. Note: The new attribute will be displayed on the diagram and added to the Browser. To turn off the attribute display Click right on the class on the diagram to make the pop up menu visible. Select the Options:Select Compartment Items menu command to make the Edit Compartment window visible. Select the attribute(s) in the Selected Items field. Click the <<<< button. Click the OK button to close the Edit Compartment window. Attributes may be created on a class diagram. They are automatically added to the Browser. They will be displayed on the diagram.
  • To create an operation on a class diagram Click right on the class on the diagram to make the popup menu visible. Select the New Operation menu command. This will add an operation called opname to the class. While the new operation is still visible, enter its name. Note: The new operation will be displayed on the diagram and added to the Browser. To turn off the attribute display Click right on the class on the diagram to make the pop up menu visible. Select the Options:Select Compartment Items menu command to make the Edit Compartment window visible. Select the operation(s) in the Selected Items field. Click the <<<< button. Click the OK button to close the Edit Compartment window. Operations may be created on a class diagram. They are automatically added to the Browser. They will be displayed on the diagram.
  • To create an additional class diagram for a package Click right on the package in the Browser to make the pop up menu visible. Select the New:Class Diagram menu command. This will add a diagram called NewDiagram to the Browser. While the new diagram is still selected, enter its name.
  • To add a class to a class diagram Click to select the class in the Browser. Drag the class onto the diagram. OR Select the Query:Add Classes menu command to make the Add Classes menu visible. Scroll up or down in the packages field to the package containing the classes you want to add to the diagram. Click to select the classes to add. Click the >>>> button to add the classes.
  • To set the stereotype display for the model Select the Tools:Options menu command to make the Options window visible. Select the Diagram tab. Select the desired radio button in the Stereotype Display field. Click the OK button to close the Options window. To set the stereotype display on a class by class basis Click right on the class on a class diagram. The stereotype of a class may be displayed on a class diagram. The default is set to display the stereotype.
  • To set line color Click to select the line on a class diagram. The Shift key may be used to do a multi-select. Select the Edit:Diagram Object Properties:Line Color menu command. Select the desired color. Click the OK button to close the Color dialog box. To set fill color Click to select the class on a class diagram. The Shift key may be used to do a multi-select. Select the Edit:Diagram Object Properties:Fill Color menu command. Select the desired color. Click the OK button to close the Color dialog box. Line and fill colors may be used in class diagrams.
  • To display all the attributes and/or operations Click right on the class on a class diagram to make the pop up menu visible. Select the Options:Show All Operations menu command to display the operations and the Options:Show All Attributes menu command to display the attributes. Note: This can be set as the default using the Tools:Options menu command, Diagram tab. To display some attributes and/or operations Click right on the class on a class diagram to make the pop up menu visible. Select the Options:Select Compartment Items menu command to make the Edit Compartment window visible. Select the operations and/or attributes to be shown on the class diagram. Click the >>>> button. Click the OK button to close the Edit Compartment window. Note: All attributes and operations created on a class diagram will be visible on the diagram. To hide them, use the Edit Compartment window. Attributes may be displayed on a class diagram. You can display all attributes or select specific ones. to display. You may do this is per diagram. That is, you can show them on one diagram and not on other diagrams.
  • To display the operation signature Click right on the class on a class diagram to make the pop up menu visible. Select the Options:Show Operation Signature menu command. Note: Set as the default using the Tools:Options menu command, Diagram tab. Attributes may be displayed on a class diagram. You can display all attributes or select specific ones. to display. You may do this is per diagram. That is, you can show them on one diagram and not on other diagrams.
  • To display visibility Click right on the class on a class diagram to make the pop up menu visible. Select the Options:Show Visibility menu command. Visibility is the export control for attribute accessor methods, the export control for operations, and the name of the owning package for classes. Note: Set as the default using the Tools:Options menu command, Diagram tab. Visibility may be displayed on class diagrams. Visibility includes export control for attributes and operations and the name of the owning package for classes.
  • To create package relationships Click to select the Dependency icon on the toolbar. Click on the package playing the role of the client. Drag the dependency line to the package playing the role of the supplier.
  • To create an association relationship Click to select the Unidirectional Association icon on the toolbar. Click on the class on the non-navigable end and drag the association line to the class on the navigable end. To create an aggregation relationship Click to select the Unidirectional Aggregation icon on the toolbar. Click on the class playing the role of the part and drag the aggregation line to the class playing the role of the whole. To create a dependency relationship Click to select the Dependency icon on the toolbar. Click on the class playing the role of the client and drag the dependency line to the class playing the role of the supplier. To create a generalization relationship Click to select the Generalization icon on the toolbar. Click on the subclass and drag the generalization line to the superclass. To create a realizes relationship Click to select the Realize icon on the toolbar. Click on the class providing the realization and drag the realize line to the class that it realizes.
  • To set navigation Click right on the association or aggregation line on a class diagram near the end that you wish to set the navigation to make the pop up menu visible. Select the Navigable menu command to toggle the navigation. Naviagation shows the direction of communication between the classes. The default for Rose is unidirectional navigation. Read the diagram ---0 The Registration Controller can send messages to the Course but the Course cannot send messages to the Registration Controller. The CourseOffering can send messages to the Student and the Student can send messages to the CourseOffering. Explain that this is NOT a data flow. Data can flow in both directions (i.e.. A message may be answered). It is showing who directs the messages.
  • To relocate an association or aggregation Click to select the association or aggregation in the Browser. Drag the association or aggregation to its new location. Explain that navigation is shown in the Browser. If an association is not navigable, then the role will be shown in the Browser but it will be grayed out. Explain this picture. The Professor has associations (or aggregations) to the CourseOffering class and the Department class. The Professor can navigate to the Department. The Professor CANNOT navigate to the CourseOffering. The CourseOffering has an association to the Professor. The CourseOffering can navigate to the Professor. STRESS that in Rose, associations and aggregations are owned by the package that owns the diagram used to create them. This means that if the classes involved in the relationship are relocated, the relationships should be relocated. This was hard to do before.
  • To name an association Click to select the association line on a class diagram. While the line is still selected, enter its name. Note: You can also name aggregations but this is not typically done since they are read using the word “contains”. Associations and aggregations may be named. The name is typically a verb or verb phrase.
  • To create a role name Click right near the end of the association or aggregation line to make the pop up menu visible. Select the Role name menu command. Enter the role name. A role denotes the purpose or capacity wherein one class associates with another. A role name is typically a noun or noun phrase.
  • To add multiplicity indicators (except specified range) Click right near the end of the association or aggregation line to make the pop up menu visible. Select the desired multiplicity indicator. To add a specified range multiplicity indicator Click right on the association or aggregation line to make the pop up menu visible. Select the Open Specification menu command. Select the appropriate tab -- Role A Detail or Role B Detail. Enter the desired range in the Cardinality field. Click the OK button to close the Specification. Read the model (at least some of it) to the class.
  • To set aggregation indicators Click right on the aggregation diamond to make the pop up menu visible. Select the Open Specification menu command. Select the Detail tab for the Class playing the role of the whole. Select the desired radio button -- by value or by reference. Click the OK button to close the Specification. Explain that a filled in diamond represents a composition aggregation. Where a composition aggregation is a form of aggregation with strong ownership and coincident lifetime as part of the whole. In Booch terms, a composition is an aggregation by value.
  • To create a reflexive relationship Click to select the association or aggregation icon on the toolbar. Click on the class. Drag the mouse button to a place on the class diagram and release the button. Depress the mouse button, drag it back to the class, and release the button. To make the line rectilinear Click to select the association or aggregation line. Select the Edit:Change Line Style:Rectilinear menu command. In a reflexive relationship, multiple objects in the same class collaborate together. Read the model. One Course in the role of a pre-requisite is related to zero to many Courses One Course is related to zero to many Courses playing the role of a pre-requisite.
  • To create a constraint that applies to the association in general Click right on the association or aggregation to make the pop up menu visible. Select the Open Specification menu command. Select the Detail tab. Enter the constraint in the Constraints field. Click the OK button to close the Specification. To create a constraint that applies to one end of the relationship Click right on the association or aggregation to make the pop up menu visible. Select the Open Specification menu command. Select the appropriate tab -- Role A Detail or Role B Detail. Enter the constraint in the Constraints field. Click the OK button to close the Specification. Note: The dependency relationship may be used to connect dependent relationships. A constraint is the expression of some condition that must be preserved. Constraints may apply to the relationship in general or they may apply to a role (one end).
  • To create a qualifier Click right near the end of the association line that is to be qualified to make the pop up menu visible. Select the New Key/Qualifier menu command. Enter the name of the qualifier. To delete a qualifier Click right on the association line to make the pop up menu visible. Select the Open Specification menu command. Select the appropriate tab -- Role A Detail or Role B Detail. Click right on the qualifier to make the pop up menu visible. Select the Delete command. Click the OK button to close the Specification.
  • To create an association class Click to select the class icon on the toolbar. Click on the diagram to place the class. While the class is still selected, enter its name. Click to select the Association class icon on the toolbar. Click on the association class and drag the line to the association. An association class is used for associations that have structure and/or behavior.
  • Hint: Enter the documentation using the Class Specification or the Documentation Window.
  • Hint: The ICourseCatalogSystem has a stereotype of Interface.
  • The is the Main diagram in the Logical View.
  • This is the Main diagram for the Business Objects package.
  • Hint: Create a new class diagram in the Business Objects package called “Course Information”
  • This is the Course Information class diagram in the Business Objects package.
  • This is the Main class diagram in the Business Objects package.
  • This is the Course Information class diagram in the Business Objects package.
  • This is the Course Information class diagram in the Business Objects package.
  • This is the Course Information class diagram in the Business Objects package.
  • This is the Course Information class diagram in the Business Objects package.
  • This is the Course Information class diagram in the Business Objects package.

04class 04class Presentation Transcript

  • Introduction to Rational Rose 98i Module 4: Class Diagram
  • Objectives: Class Diagram
    • You will be able to:
      • Create classes
      • Add attributes and operations to classes
      • Create stereotypes for classes
      • Create packages
      • Relocate classes
      • Create class diagrams
      • Create relationships
  • Classes in the Browser
  • Namespaces
  • Documenting Classes
  • Using the Class Specification - Stereotypes
  • Using the Class Specification - Attributes
  • Using the Class Specification - Operations
  • Attributes and Operations and the Browser
  • Attribute Visibility Options
  • Operation Visibility Options
  • Packages in the Browser
  • Moving Classes to Packages
  • What is a Class Diagram?
    • A class diagram is a view of the static structure of a system
      • Models contain many class diagrams
    • Class diagrams contain:
      • Packages, classes, interfaces, and relationships
    • Notation:
    Package Name Class Name Interface Name <<Interface>>
  • The Main Class Diagram
    • The logical view initially contains one class diagram
      • This diagram is called Main
    • The Main class diagram is typically a view of the high level packages in the logical view
  • Class Diagram Drawing Toolbar Text Attachment Association Relationship Association Attribute Dependency Relationship Inherits Relationship Package Selection Tool Note Class Aggregation Relationship Interface Realizes Relationship
  • Main Class Diagram-Registration System
  • Main Diagram Business Services Package
  • Creating Classes on a Class Diagram
  • Class Name Completion
  • Creating Attributes via a Class Diagram
  • Creating Operations via a Class Diagram
  • Additional Class Diagrams
    • Additional class diagrams are added as needed
    • They show additional “views” of the packages and classes in the model
    • Examples:
      • View of classes participating in a scenario
      • View of the “private” classes in the package
      • View of one or more classes and their attributes and operations
      • View of an inheritance hierarchy
  • Additional Class Diagram
  • Showing Stereotypes
  • Color
  • Displaying Attributes and Operations
  • Displaying the Operation Signature
  • Displaying Visibility
  • Relationships
    • Class diagrams may contain the following relationships:
      • Association, aggregation, dependency, realize, and inheritance
    • Notation:
    Association Aggregation Dependency Inheritance Realize
  • Package Relationships
  • Class Relationships
  • Navigation Unidirectional Bi-directional
  • Associations / Aggregations in the Browser Navigable Not Navigable
  • Naming Associations
  • Role Names
  • Multiplicity Indicators
    • Each end of an association or aggregation contains a multiplicity indicator
      • Indicates the number of objects participating in the relationship
    Zero or more 0..* One or more 1..* Zero or one 0..1 Specified range 2..7 Exactly one 1
  • Multiplicity Indicators
  • Aggregation Indicators
  • Reflexive Relationships
  • Constraints
  • Qualifiers
  • Association Classes
  • Deleting
    • If a package, class, association, or aggregation is deleted from the Browser then it is deleted from the model
    • If a package, class, association, or aggregation is deleted from a Class Diagram, it is deleted from the diagram but still remains in the model
  • Exercise: Classes
    • Use the pictures on the following pages to create the packages, classes, and class diagrams for your model
  • Exercise: Classes in the Browser
  • Exercise: Documenting Classes
  • Exercise: Stereotypes
  • Exercise: Packages in the Browser
  • Exercise: Relocating Classes
  • Exercise: Creating Attributes
  • Exercise: Creating Operations
  • Exercise: The Main Class Diagram
  • Exercise: Package Main Class Diagram
  • Exercise: Additional Class Diagram
  • Exercise: Displaying Attributes/Operations
  • Exercise: Relationships
  • Exercise: Relationships
  • Exercise: Reflexive Relationships
  • Exercise: Role Names
  • Exercise: Multiplicity
  • Exercise: Constraints