Saturday, November 9, 2019

Rational Rose Manual

Visualize with Rational Software Architect Create and transform a UML 2. 0 model into code Skill Level: Introductory Eric Long ([email  protected] ibm. com) Software Engineer IBM 21 Mar 2006 Rational Software Architect virtually teems with visual tools to handle a number of development tasks. Of most interest to developers are UML modeling, design patterns, and UML-to-code transformations. After completing this tutorial, you will know how to create a UML model, apply a design pattern to that model, and, finally, transform the abstract model into actual code. Section 1. Before you startRational ® Software Architect provides developers, architects, and analysts visual tools for a wide variety of software development tasks. This tutorial introduces a few of these powerful visual tools: UML modeling, design patterns, and UML transformations. About this tutorial Learn how to create, edit, and analyze UML models using Rational Software Architect. This tutorial demonstrates the followin g Rational Software Architect capabilities: †¢ UML modeling Visualize with Rational Software Architect  © Copyright IBM Corporation 2006. All rights reserved. Trademarks Page 1 of 22 developerWorks ® ibm. com/developerWorks Design patterns †¢ UML transformations This tutorial is intended for software developers, architects, and analysts interested in learning about Rational Software Architect's visual modeling capabilities. If you want to learn how to transform high-level UML models into actual code without even knowing a particular programming language, this tutorial is for you. Objectives After completing this tutorial, you will know how to use Rational Software Architect to create UML projects and models, apply design patterns to those models (new or existing), and transform UML models into source code or into a different type of model.Prerequisites This tutorial assumes that you have some knowledge of Javaâ„ ¢ programming, and design patterns. Knowledge of UML m odels is helpful, but not required. System requirements To run the examples in this tutorial, install Rational Software Architect. If you don't have a copy of Rational Software Architect, download a free trial version. All of the prerequisites for Rational Software Architect are located in the Resources section of this tutorial. Section 2. Create a UML modeling project To get started, you need to do some initial set up. First, create a UML project and model. StepsCreating a UML modeling project is very easy: Visualize with Rational Software Architect  © Copyright IBM Corporation 2006. All rights reserved. Trademarks Page 2 of 22 ibm. com/developerWorks developerWorks ® 1. 2. 3. 4. 5. 6. 7. Open Rational Software Architect. Open the Modeling perspective by selecting Open Perspective > Modeling from the Window menu. Make sure all of your open projects are closed. Select New > Project†¦ from the File menu. Ensure the Show All Wizards box is checked. Expand the Modeling folder. Select UML Project. Figure 1. The New Project window 8. 9. Click Next.Name your project DWorksPatternProject. Figure 2. UML Modeling Project window Visualize with Rational Software Architect  © Copyright IBM Corporation 2006. All rights reserved. Trademarks Page 3 of 22 developerWorks ® ibm. com/developerWorks 10. Click Next. 11. Fill in the Create a UML project wizard as follows: †¢ Select UML Modeling for the File types. †¢ Select Blank Model for the Templates. †¢ Enter PatternModel for the File name. †¢ Leave the remaining defaults. The wizard should look like this: Figure 3. Create UML Model window Visualize with Rational Software Architect  © Copyright IBM Corporation 2006.All rights reserved. Trademarks Page 4 of 22 ibm. com/developerWorks developerWorks ® 12. Click Finish. 13. The Model Explorer view contains your UML Project, DWorksDesignPattern and your blank UML model, PatternModel. emx. Figure 4. Current Model Explorer view Visualize with Rati onal Software Architect  © Copyright IBM Corporation 2006. All rights reserved. Trademarks Page 5 of 22 developerWorks ® ibm. com/developerWorks See, wasn't that easy? Now, on to the more exciting part of the tutorial. Let's build the model using RSA's user-friendly visual tools. Section 3. Model a design patternNow it's time to select a design pattern, apply that design pattern to a model, observe all relationships of the pattern, and add attributes and operations to the model. Design patterns in RSA Rational Software Architect comes packaged with support for all of the Gang of Four design patterns. You also have the ability to import and create your own design patterns. Select a design pattern 1. 2. Select Show View > Other†¦ from the Window menu. Expand the Modeling folder and select Pattern Explorer. Figure 5. Select Pattern Explorer Visualize with Rational Software Architect  © Copyright IBM Corporation 2006.All rights reserved. Trademarks Page 6 of 22 ibm. com/devel operWorks developerWorks ® 3. 4. 5. Click OK. In the Pattern Explorer view, expand Design Patterns > Behavioral. Select the Observer pattern. Figure 6. The Observer Design Pattern Visualize with Rational Software Architect  © Copyright IBM Corporation 2006. All rights reserved. Trademarks Page 7 of 22 developerWorks ® ibm. com/developerWorks 6. 7. 8. To learn about the pattern, toggle between the Overview and Short Description tabs at the bottom of the Pattern Explorer view. In the Pattern Explorer view, drag-and-drop Observer onto DesignPattern's blank diagram.The editor should contain an instance of the Observer Design Pattern that looks like this: Figure 7. Observer Pattern Instance Visualize with Rational Software Architect  © Copyright IBM Corporation 2006. All rights reserved. Trademarks Page 8 of 22 ibm. com/developerWorks developerWorks ® Apply a design pattern 1. In DesignPattern's editor, hover over ConcreteObserver and select Enter argument name/value†¦. Fi gure 8. Enter argument 2. Name the parameter Shopper, then press Enter. The Observer instance now has a concrete observer named Shopper. Let's add a parameter using a different approach.From the Palette (right of diagram), click to expand the Class Diagram section. Figure 9. Palette 3. Visualize with Rational Software Architect  © Copyright IBM Corporation 2006. All rights reserved. Trademarks Page 9 of 22 developerWorks ® ibm. com/developerWorks 4. 5. 6. Select Class and click anywhere in the diagram (do not click on the Observer instance). Name the newly created class Order and press Enter. Drag-and-drop Order onto ConcreteSubject in the Observer instance. Figure 10. Drag-and-drop ConcreteSubject Visualize with Rational Software Architect  © Copyright IBM Corporation 2006.All rights reserved. Trademarks Page 10 of 22 ibm. com/developerWorks developerWorks ® 7. Your diagram should look similar to this (you might not see all of the relationships†¦ you'll fix that in the next section). Figure 11. Observer instance Observe the design pattern relationships 1. Right-click on any element in the DesignPattern diagram. Visualize with Rational Software Architect  © Copyright IBM Corporation 2006. All rights reserved. Trademarks Page 11 of 22 developerWorks ® ibm. com/developerWorks 2. Select Filters > Show Related Elements†¦ from the context menu.Figure 12. Show relationships 3. Select Show All Relationships from the Custom Query list. Figure 13. Show/Hide Relationships Visualize with Rational Software Architect  © Copyright IBM Corporation 2006. All rights reserved. Trademarks Page 12 of 22 ibm. com/developerWorks developerWorks ® Visualize with Rational Software Architect  © Copyright IBM Corporation 2006. All rights reserved. Trademarks Page 13 of 22 developerWorks ® ibm. com/developerWorks 4. 5. Click OK You can see all of the elements and relationships represented in this model: Figure 14. Observer pattern 6.Now you are ready to add some elements to your blank Observer design pattern model. Add methods and attributes to a model Visualize with Rational Software Architect  © Copyright IBM Corporation 2006. All rights reserved. Trademarks Page 14 of 22 ibm. com/developerWorks developerWorks ® 1. 2. In the PatternModel editor, right-click the Order concrete subject. Select Add UML > attribute. Figure 15. Add attribute 3. 4. 5. 6. 7. 8. 9. Type -orderNum : String (the â€Å"-† makes the attribute private). Press Enter. Repeat the same steps on Shopper, but name the attribute -custID : String.In the PatternModel editor, right-click the Shopper concrete subject. Select Add UML > operation. Type +makeOrder() (the â€Å"+† makes the operation public). PatternModel's editor should now look like this: Figure 16. Observer pattern Visualize with Rational Software Architect  © Copyright IBM Corporation 2006. All rights reserved. Trademarks Page 15 of 22 developerWorks ® ibm. com/developerWorks Good work ! You have completed your model (a very simple model) and can use Rational Software Architect's tools to transform this model into actual code. Section 4. Transform your model into Java codeNow that you have a completed model within your UML project, you are going to transform that model to actual code. Rational Software Architect supports the Visualize with Rational Software Architect  © Copyright IBM Corporation 2006. All rights reserved. Trademarks Page 16 of 22 ibm. com/developerWorks developerWorks ® following model-to-code transformations out of the box: †¢ UML -> Java †¢ UML -> EJB †¢ UML -> XSD †¢ UML -> CORBA †¢ UML -> C++ However, if you would like more options, there are built-in tools and wizards that let you create custom transformations in Rational Software Architect.You are going to transform your existing model into Java. Transform a UML model to Java code 1. In the Model Explorer view, expand DWorksPatternProject. Figure 17. Expanded pro ject 2. 3. In the Model Explorer view, select both Order and Shopper. Right-click on either of the selected objects and select Transform > Run Transformation > UML – Java. Figure 18. Run transformation Visualize with Rational Software Architect  © Copyright IBM Corporation 2006. All rights reserved. Trademarks Page 17 of 22 developerWorks ® ibm. com/developerWorks 4.In the Run this Transformation window, click Create new Target Container†¦. Figure 19. Transformation window Visualize with Rational Software Architect  © Copyright IBM Corporation 2006. All rights reserved. Trademarks Page 18 of 22 ibm. com/developerWorks developerWorks ® 5. In the New Java Project window, name the project DWorksTransformedJava. Figure 20. New Java project Visualize with Rational Software Architect  © Copyright IBM Corporation 2006. All rights reserved. Trademarks Page 19 of 22 developerWorks ® ibm. com/developerWorks 6. 7. Click Finish.Now that you are back in the Run this Trans formation window, click Run. RSA transforms the model into Java source code. The Model Explorer view should contain this Java project: Figure 21. Transformed Java project 8. Double-click Order. java to see the transformed code. The code should look like this: Figure 22. Transformed Order class Visualize with Rational Software Architect  © Copyright IBM Corporation 2006. All rights reserved. Trademarks Page 20 of 22 ibm. com/developerWorks developerWorks ® Try running a different transformation from UML-to-C++ and explore the results. Section 5. Conclusion Congratulations!In this tutorial, you covered the creation of a UML project and model, selecting and applying a design pattern to a model, adding and editing attributes and operations to a model, and transforming that model into actual code. You did all of this without even writing a line of code! It is easy to see (even with this simple tutorial) how visual UML modeling tools simplify code development. At this point, you might want to explore some of the links in the Resources section of this tutorial. Visualize with Rational Software Architect  © Copyright IBM Corporation 2006. All rights reserved. Trademarks Page 21 of 22 developerWorks ® ibm. om/developerWorks Resources Learn †¢ Visit the developerWorks Rational zone to expand your Rational skills. †¢ â€Å"Exposing Design flaws in your code: Part 1†³ (developerWorks, August 2005) details the visual tools available to run internal code reviews in Rational Software Architect. †¢ † Visualize with Rational Application Developer† (developerWorks, February 2006) details the visualization capabilities of Rational Application Developer. †¢ â€Å"Discover IBM Rational visual tools for application development† (developerWorks, February 2006) covers all of the different visual tools available in the Rational Software Development Platform. Stay current with developerWorks technical events and webcasts. Get product s and technologies †¢ Download a free trial version of Rational Software Architect. †¢ Build your next development project with IBM trial software, available for download directly from developerWorks. Discuss †¢ Participate in developerWorks blogs and get involved in the developerWorks community. About the author Eric Long Eric Long is a Software Engineer in the IBM Developer Skills Program. Eric graduated from The University of Texas with a degree in Computer Science.He joined IBM in July of 2004 and currently works in Austin, Texas. As a Software Engineer, he provides technical information to developers on open source and industry trends and technologies through speaking engagements, web content, and faculty consultations at IBM Academic Initiative member universities. His work also includes technical courses, demos, articles, and tutorials available at http://www. ibm. com/university and http://www. ibm. com/developerworks. Visualize with Rational Software Architec t  © Copyright IBM Corporation 2006. All rights reserved. Trademarks Page 22 of 22

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.