Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Hello World: Rational Software Architect V7

Design and implement a simple phone book application (updated)

Tinny Ng (tng@ca.ibm.com), Advisory Software Developer, IBM Toronto
Tinny Ng
Tinny Ng is a scenario architect at the IBM SWG Scenario Analysis Lab, whose mission is to improve the cross-brand integration capability of IBM SWG products. She has more than 10 years of experience in software development, from design to implementation, including application building, packaging, testing, and support.
(An IBM developerWorks Contributing Author)

Summary:  This first tutorial in the Hello World series has been updated for Rational Software Architect V7. Hands-on exercises walk you through every step of designing and implementing a service-oriented application using Rational® Software Architect V7, including using UML diagrams to design and model an application, publishing the model information to a Web page, and transforming the design to Java™ code. It concludes with an introduction to Rational Software Architect V7's new true round-trip engineering (RTE), which makes it possible to forward- and reverse-engineer Java code, giving you a head-start on implementing your designs.

View more content in this series

Date:  20 Feb 2007
Level:  Intermediate PDF:  A4 and Letter (2079 KB | 38 pages)Get Adobe® Reader®

Activity:  42627 views
Comments:  

Create a class diagram

Class diagrams are the blueprints of your system. You can use class diagrams to model the objects that make up the system, to display the relationships between the objects, and to describe what those objects do and the services they provide.

You'll design the simple phone book application using the Model-View-Controller (MVC) architecture pattern, as shown in Figure 7. (See Resources to learn about MVC.) For the phone book application you'll need to create the following three classes:

  • PhoneBookModel manages the phone book entries and captures the state of the application. Whenever the state is changed, it notifies PhoneBookView, which should then refresh the user interface based on the state of the application.
  • PhoneBookView manages the graphical or textual interface to the user based on the state of the application, and notifies PhoneBookController when an input is received.
  • PhoneBookController controls the operation of the entire application. It changes the model state of the application and updates the data model based on user input.

The purpose of this exercise is to show you how to use Rational Software Architect when designing an application. The design itself is not the focus. You may proceed with a different design if you prefer.


Figure 7. MVC design for the phone book application
MVC design for the phone book application

Would you like to see these steps demonstrated for you?

Show meShow me

Now create a class diagram that reflects the design in Figure 7.

  1. In Rational Software Architect's Model Explorer view, right-click Phone Book UML Model and select Add Diagram > Class Diagram.
  2. Enter Class Diagram as the name of the generated diagram to replace the default name ClassDiagram1.
  3. Select Class in the Palette, then click anywhere in the diagram to create a class. Name it PhoneBookModel.
  4. Right-click the created class PhoneBookModel and select Add UML > Operation to create an operation for this class. Name it setState.
  5. Similarly, create the rest of the elements as shown in Table 2. The operation names are chosen without assumptions regarding the programming language used.
ClassOperation(s)
PhoneBookModeladdAnEntry
searchPhoneNumber
getSearchResult
getState
PhoneBookViewstateHasChanged
changeView
getUserInput
PhoneBookControlleruserHasInput
start
  1. Next you'll create some associations to relate these three classes. As shown in Figure 8, click the arrow that appears next to Association from the Palette and select Directed Association.

    Figure 8. Selecting Directed Association from the Palette
    Selecting Directed Association from the Palette

  2. Draw the association relationship line from the class PhoneBookController to PhoneBookModel (the order is important) to initiate a directed association relationship between these two classes. A directed association relationship means the first class is aware of the second one, but not the other way around.
  3. Name this directed association relationship controllerHasModel.
  4. Now that you've done it once, create a couple more relationships. This time create association relationships without direction, which means the two connected classes are mutually aware of each other:
    • Create an association relationship between the class PhoneBookModel and PhoneBookView and name it modelView.
    • Create an association relationship between the class PhoneBookView and PhoneBookController and name it viewController.
  5. The complete class diagram should look similar to Figure 9. Select Ctrl-S to save the diagram.

    Figure 9. A complete class diagram for the phone book application
    A complete class diagram for the phone book application

7 of 15 | Previous | Next

Comments



static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Rational
ArticleID=196561
TutorialTitle=Hello World: Rational Software Architect V7
publish-date=02202007
author1-email=tng@ca.ibm.com
author1-email-cc=