Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Overview
Hello World: very simple phone book application Stores user entered phone numbers to be retrieved later. Adapted to a presentation from: http://www.ibm.com/developerworks/edu/i-dw-rhellorsa.html
Steps
Create a UML project Create a use case diagram Create a class diagram Create a sequence diagram Publish the design
Steps
Create a UML project Create a use case diagram Create a class diagram Create a sequence diagram Publish the design
Retrieve a phone number by entering a unique person name using the provided application user interface. The system locates the phone number and returns it to the actor.
Create a use case diagram (3-5) 3. Select Actor in the Palette, then click anywhere in the diagram to create an Actor. Name it Any User. 4. Select Use Case in the Palette, then click anywhere in the diagram to create a Use Case. Name it Add an entry. 5. Similarly, create another use case called Search for a phone number.
Create a use case diagram (6-7) 6. Select Association in the Palette. Draw the association relationship line from the actor Any User to the use case Add an entry to initiate a relationship between the two model elements. 7. Similarly, create another association relationship between the actor Any User and the use case Search for a phone number.
Steps
Create a UML project Create a use case diagram Create a class diagram Create a sequence diagram Publish the design
Conceptual Design
Class: 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
Class: PhoneBookView
Manages the graphical or textual interface to the user based on the state of the application Notifies PhoneBookController when an input is received
Class: PhoneBookController
Controls the operation of the entire application. Changes the model state of the application and updates the data model based on user input.
Class Operations
PhoneBookModel
addAnEntry searchPhoneNumber getSearchResult getState
PhoneBookView
stateHasChanged changeViewgetUserInput
PhoneBookController
userHasInput start
8.
Steps
Create a UML project Create a use case diagram Create a class diagram Create a sequence diagram Publish the design
Sequence Description
The actor Any User makes use of the interface provided by PhoneBookView to request a search. PhoneBookView notifies PhoneBookController about the user's request. PhoneBookController then updates the data model that is stored in PhoneBookModel. Because there is a change of the model, PhoneBookModel notifies PhoneBookView, which should then refresh the user interface to reflect the latest state of the application.
From instance
phoneBookView phoneBookController phoneBookController phoneBookModel phoneBookView phoneBookView
Operation
PhoneBookController::userHasInput() PhoneBookModel::searchPhoneNumber() PhoneBookModel::setState() PhoneBookView::stateHasChanged() PhoneBookModel::getSearchResult() PhoneBookView::changeView()
Steps
Create a UML project Create a use case diagram Create a class diagram Create a sequence diagram Publish the design
Steps
Create a UML project Create a use case diagram Create a class diagram Create a sequence diagram Publish the design
Transform UML to Java (1-3) 1. In the Model Explorer view, rightclick Phone Book UML Model and select Transforms > UML to Java. Select Create new Target Container... 2. In the New Java Project panel, enter PhoneBookJavaProject as the Java project name, and select Create separate source and output folder. Select Finish. 3. Select Run to start the transformation.
Transform UML to Java (4) 4. In the Model Explorer view, a Java project PhoneBookJavaProject is created automatically with three Java files underneath.
PhoneBookController.java Stubs
Steps
Create a UML project Create a use case diagram Create a class diagram Create a sequence diagram Publish the design
Implementation
Sample implementation uses a command line interface and stores the phone entries into a local file. Alternative implementations could be carried out Example: Create a GUI interface instead of a command line interface, store the data with EJB components instead of to a file Use the Observer pattern to implement the notification mechanism
Sample Implementation
1. Copy and paste the sample implementation into stubs.
Sample Implementation