As mentioned in Part 1 of this series, to use the model-driven and pattern-based development approach, you need an integrated development environment (IDE) that can support:
- Modeling, using the Unified Modeling Langugage (UML)
- A patterns infrastructure
- Model transformation and code generation
- A platform-specific design and development tool
- A unit test environment
IBM® Rational® Software Architect not only provides these capabilities to support the end-to-end model-driven development (MDD), but also provides the value-added functionalities to support asset-based development, which complements MDD by supporting the reuse of models, patterns, and transformations (see Figure 1).
Figure 1. Integrated development environment
This article, Part 2 of the series, highlights the key tooling support of IBM Rational Software Architect that is related to model-driven development, patterns, and asset-based development. A simple scenario will guide you through those features.
Modeling using UML
Models have become primary artifacts of software design, thereby shifting much of the focus away from the corresponding program code. Thus, models not only allow you to capture and communicate all aspects of application architecture but also serve as blueprints from which various automated and semiautomatic processes derive programs and related models. Therefore, you can use models for the following purposes:
- Visually represent the system that you want to build
- Foster a common understanding of a system
- Develop, verify, and communicate a system’s architecture
- Generate code
Rational Software Architect integrates a powerful UML software modeling framework, and it fully supports modeling using UML 2.0, the first major revision of the UML standard. This means that it can support MDD tools and methods better, which helps you capture and communicate the intent of your design.
In UML modeling, models contain elements, such as actors, use cases, classes and packages, as well as one or more diagrams that show specific perspectives of a system, such as an activity diagram or a class diagram.
The Rational Software Architect Modeling Perspective
Rational Software Architect provides a modeling perspective that is a composite of the following related views.
The Model Explorer (Figure 2) shows the modeling projects that may contain any number of models. A model (which is a model element in itself) contains corresponding model elements, such as packages, classes, parameters, operations, and constraints. From the Model Explorer, you can add, delete, sort, and organize model elements, and you can also open a UML diagram in a diagram editor.
Figure 2. The Model Explorer view
The Diagram Navigator takes a different view of projects in the workspace. It displays the modeling projects, the UML models, and their UML diagrams in a directory (tree) view, as Figure 3 shows.
Figure 3. The Diagram Navigator view
UML diagrams help you visualize and manipulate the elements in a model. Different diagrams represent different views of the system, application, or database that you are developing. Because diagrams can illustrate multiple views of a model, the same model element can appear in one or more diagrams.
UML provides various diagrams that let users capture and communicate all aspects of an application architecture by using a standard notation that is recognized by many stakeholders. These are the 13 official UML 2.0 diagrams, each of which shows different aspects of the system:
- Activity diagram: An activity diagram provides a view of the behavior of a system by describing the sequence of actions in a process. Besides showing the flow between the actions in an activity like a flowchart, the activity diagram can also show parallel or concurrent flows and alternate flows.
- Class diagram: 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 that they provide. Class diagrams are fundamental to the object modeling process and useful in the analysis and design stages.
- Communication diagram: Formerly known as the Collaboration diagram in UML 1, a communication diagram shows the message flow between objects and shows how several objects collaborate together to fulfill a common purpose. Similar to the sequence diagram, the communication diagram can also model the dynamic behavior of the use case. However, a communication diagram focuses more on showing the collaboration of objects than on the time sequence.
- Component diagram: A component diagram shows the structural relationships between the components of a system. In UML 2, components are autonomous, encapsulated unites within a system or subsystem that provide one or more interfaces. Therefore, a component diagram allows an architect to verify that components are implementing a system's required functionality.
- Composite structure diagram: A composite structure diagram explores runtime instances of interconnected instances collaborating over communication links.
- Deployment diagram: A deployment diagram depicts a static view of the runtime configuration of processing nodes and the components that run on those nodes (the hardware for your system, the software that is installed on that hardware, and the middleware used to connect the disparate machines to each other).
- Interaction overview diagram: An interaction overview diagram is a variant of the activity diagram in which the nodes represent interaction diagrams. Interaction diagrams can include sequence, communication, an interaction overview, and timing diagrams.
- Object diagram: Use an object diagram to explore real- world examples of objects and the relationships between them. An object diagram looks similar to the class diagram, because the notation of the relationships is the same. It is a good option to explain complicated relationships among objects.
- Package diagram: A package diagram allows you to organize model elements into groups depicted as file folders, which makes UML diagrams simpler and easier to understand.
- Sequence diagram: A sequence diagram illustrates the chronological sequence of messages between objects in an interaction. It consists of a group of participants, such as actors, systems or subsystems, classes, and components that are represented by lifelines, as well as the messages that they exchange during the interaction.
- State machine diagram: A state machine diagram depicts the various states that an object may be in and the transitions between those states.
- Timing diagram: A timing diagram explores the behaviors of one or more objects during a specified period of time.
- Use case diagram: Use a use case diagram to visualize (or illustrate) the relationships between use cases and actors and between use cases and other use cases.
You can open a UML diagram in the Diagram Editor (Figure 4) either from the Diagram Navigator or from the Model Explorer view. You can select multiple diagrams to open at the same time, and then use the tabs to switch between open diagrams.
A UML diagram contains diagram elements. A diagram element, also called a shape, is a graphic or text element that represents either a UML element (such as class, interface, and relationship), or a geometric shape that does not have any UML semantics (such as ovals, diamonds, and rectangles). From the Diagram Editor, you can drag an existing model element into the diagram from the Model Explorer, or you can use the palette to create a new diagram element. (If the diagram element represents a UML element, its corresponding UML element will be added to the model.)
Figure 4. The Diagram Editor view
If you highlight a diagram element from a UML diagram, you can see and set the properties of a diagram element from the Properties view (Figure 5). Properties are values that govern the characteristics of shapes and connectors in UML diagrams. For example, each shape and connector has a line-color property that you can specify for the color of the shape's borders or the connector line. You can also specify property values to change connector line styles and to show or hide compartments or compartment titles.
If you highlight a model element from the Model Explorer, you can view and set the properties of the model element, such as names and visibility, the profiles of a model, and attributes and operations of a class.
Figure 5. The Properties view
Rational Software Architect includes templates for the use case, analysis, and design models. Each is targeted for different development phases: requirements, analysis, and design.
Rational Software Architect does not provide the template for the implementation model, which represents the physical composition of the implementation, including the implementation subsystems and implementation elements (source code, data and executable files). The reason it does not include the implementation templates is that the Rational Software Architect theory of operation is to use platform-neutral models through design, and then have Rational Software Architect transform these designs, via a variety of different transformations, into code or implementation-level artifacts.
Use case model
The use case model provides detailed information about the behaviors of the system or application that you are developing. It identifies the requirements of the system in terms of the functionality that must exist (use cases) to achieve the goals or to solve a problem identified by the user, and it specifies the surroundings (actors) and the relationships between the use cases and the actors (use case diagrams). The use case model also includes use case diagrams and activity diagrams that describe how users interact with the system.
The analysis model describes the structure of the system or application that you are modeling. It consists of class and sequence diagrams that describe the logical implementation of the functional requirements that you identified in the use case model.
The analysis model identifies the main classes in the system and contains a set of use case realizations that describe how the system will be built. Class diagrams describe the static structure of the system by using stereotypes to model the functional parts of the system. Sequence diagrams realize the use cases by describing the flow of events in the use cases when they are executed. These use case realizations model how the parts of the system interact within the context of a specific use case.
The analysis model describes the logical structure of the system; thus it is the foundation of the design model.
The design model is based on the analysis model and adds details to the actual implementation of the system. By using a variety of diagrams (including sequence, state machine, component, and deployment diagrams), the design model describes in detail how the application is structured and how it will be implemented. It also describes programming constructs and technologies, such as those used for persistence, distribution, security, and logging.
Design patterns usually refine the design model to capture frequently used or complex structures and processes.
As mentioned in the design model section previously, you can use design patterns to refine the design model (modify or add UML elements) to apply a solution to a known problem. You can use the pattern framework of Rational Software Architect to accomplish several key tasks:
- Author the pattern
- Package the pattern as a reusable asset in the form of a plug-in
- Find and navigate to patterns in the pattern library
- Apply patterns to UML elements
You can author a design pattern by extending two plug-ins: a pattern service and a pattern framework that abstracts the use of the pattern service. The pattern service and pattern framework provide the basic functions to structure, design, code, search for, organize, and apply patterns.
The "Content authoring demystified" article (see Resources) describes in detail how to author a new pattern.
Packaging and publishing patterns for reuse
You can export a pattern plug-in as a deployable, reusable asset that conforms to the Reusable Asset Specification (RAS), so that it can be used again later. The reusable asset can be exchanged as a file or be published to a shared asset repository for other people to search and then conveniently import the pattern into their Rational Software Architect workbenches.
The "Content authoring demystified" article (see Resources) also describes how to package a pattern as a RAS asset file and export it to the file system. Alternatively, you may want to export the asset directly to a repository, as Figure 6 shows.
Figure 6. Exportng a pattern to an asset repository
There are multiple ways to find a pattern from Rational Software Architect, such as using the Pattern Explorer and the Asset Explorer.
Pattern Explorer: From the modeling perspective, click the icon that normally resides on the right-most side of the screen. The pattern navigator will display, showing the patterns installed by Rational Software Architect, which ships with Gang of Four (GoF) design patterns. If you have imported other patterns, they will also be listed. From the Pattern Explorer (Figure 7), you can search, organize, or drag a pattern into a UML diagram.
Figure 7. Pattern Explorer view
Asset Explorer: All patterns are stored by default in a pattern-type, local RAS repository, which you can organize into logical groups, or subdirectories. From the Asset Explorer view of the RAS perspective, you can find patterns installed by Rational Software Architect under the Patterns Repository directory.
If you have created connections to any asset repository, either local or remote, you can also find patterns from the connected asset repositories if they have been published by contributors, as shown in Figure 8. You can import the patterns from the asset repository to your Rational Software Architect workspace so that you can use them from the Pattern Explorer.
Figure 8. Asset Explorer view
Applying patterns is quite straightforward. You can drag a pattern instance from the Pattern Explorer to a UML diagram, and then bind UML elements to the pattern instance as parameters (select existing ones or create new ones). After you have bound the parameters to the pattern instance, the pattern instance will refine the model by modifying existing model elements or adding new ones.
You'll find more information about applying patterns, along with an example, later in this article.
As mentioned earlier, you can transform the design model into implementation-level artifacts in Rational Software Architect, such as executable code, XSD, WSDL, documentation, and configuration scripts.
Rational Software Architect ships with five transformations, as shown in Figure 9. You can apply these transformations to different levels of the UML elements, such as model, package, class, and interface. For instance:
- UML to C++
- UML to Java
- UML to EJB
- UML to CORBA
- UML to XSD
These transformations provide the basic functions to generate the corresponding Eclipse projects and related artifacts from an UML model. For example, the UML to Enterprise Java® beans (EJB) transformation will create an EJB project, whereas the UML to Java transformation will create a Java project. You can extend these transformations to add behavior, or you can write your own transformation by extending the Rational Software Architect transformation framework. The "Content authoring demystified" article (see Resources) shows an example of how to extend the UML to Java transformation, as well as an example of how to create your own Rational Software Architect transformation.
Figure 9. Transformations included in the Rational software
Asset-based development framework
Models, patterns, and transformations are reusable assets. After they are developed, they can be organized, stored and used by others to accelerate MDD and to ensure better returns on investments. As a result, asset-based development is an important complement ito MDD.
Rational Software Architect uses the Reusable Asset Specification (RAS) to provide a standard way to package and consume (use) assets that provide a solution to a problem for a given context. A RAS asset is a collection of related artifacts with a manifest that describes the asset, as shown in Figure 10. Artifacts are any work products from the software development lifecycle, such as requirements documents, models, source code files, deployment descriptors, test cases, and scripts. In general, the termartifact is associated with a file.
Figure 10. What constitutes an asset
Packaging assets for reuse
Using the RAS export capability of the Rational Software Architect modeling tools to package assets ensures that all referenced files are automatically captured with the relevant models and projects, documentation, source code, and other development artifacts that you want to share. (For more information, read the "Content authoring demystified" article cited in Resources.) After the asset is packaged, you have the option to save it in your local file system or export it to an asset repository.
Importing existing assets
The RAS import capability in Rational Software Architect unpacks and restores the files in the RAS asset to a local file or folder or to the Eclipse workspace. Importing assets with deployable plug-ins, such as patterns and transformations, will result in an attempt to install the plug-ins in Rational Software Architect. You can import assets from either a local file system or an asset repository.
RAS assets can be stored in RAS-based asset repositories. With Rational Software Architect, when you package an asset, you have the option to export it to a connected asset repository. You may also publish an asset in .ras file format from the file system to a connected repository from the Asset Explorer view of the RAS perspective.
In addition, you can view, search, and import assets from the asset repositories from the Asset Explorer, as Figure 8 shows. Rational Software Architect supports the following four types of RAS-based asset repositories. You can create a connection to these repositories from the Asset Explorer view.
- Local repository: A local file system repository for personal use. You cannot share this repository within a team unless you use a network file system to host the local repository.
- Workgroup repository: A Web service-based repository for team use. This is a Java® 2 Platform, Enterprise Edition (J2EE®) application that you can install on a J2EE application server. It can then be used to share assets within a team that has Rational Software Architect installed. You can download the workgroup repository from IBM® alphaWorks® (see Resources).
- XDE repository: This option provides backward support for a legacy Rational XDE repsitory.
- developerWorks repository: This is hosted by IBM® developerWorks®. You can search and import new design patterns that are contributed by IBM. The number of patterns is growing steadily, so don't forget to check it frequently.
Putting everything together: A simple scenario
Now it is time to learn how to put all of the MDD tooling support together. This scenario walks you through these steps:
- Store a design pattern asset in an asset repository
- Navigate to the repository and import the design pattern
- Create a UML model
- Apply the Interface Inheritance design pattern to the UML model
- Transform the model into Java code
Step 1. Store a design pattern asset in an asset repository
- Download the Interface Inheritance design pattern from the Downloads section of this article. When this pattern is applied to a class, the design pattern will extract the public operations of the class into an interface and create an inheritance relationship between the class and the interface.
- Create a connection to a
- From Rational Software Architect, launch the RAS (Reusable Asset) perspective.
- From the Asset Explorer view, create a connection to a repository by clicking the icon.
- If you have installed a Workgroup Repository, select Workgroup Repository and enter the URL of you repository instance; otherwise, select Local Repository, and enter the location where you want to store the assets.
- Import the pattern asset into the repository.
- From the Asset Explorer view, right-click to bring up the context menu, and then select Publish Asset....
- Locate the asset file that you downloaded, and select the repository from the list to publish it. (See Figure 11.)
- After the asset is published, the Interface Inheritance pattern will show in the list of assets under the connected repository.
Figure 11. Importing the pattern asset into the repository
Step 2. Navigate the repository and import the design pattern
- Navigate to the assets and search them. From the Asset Explorer, you can navigate through the assets from different repositories and use the icon to open a search dialog to search the assets.
- Import the design
- Right-click the Interface Inheritance asset, and select Import... from the context menu. The Import RAS Asset wizard will launch. A message window informs you that the asset contains deployable plug-ins and that importing it will result in an attempt to install the plug-ins. Click OK to acknowledge that information.
- Complete the import wizard process.
- The pattern plug-in should then be dynamically loaded by
Rational Software Architect. Switch to the Modeling
perspective, click the icon to open
the Pattern Explorer. You should see Interface Inheritance
pattern under the Miscellaneous Patterns category.
Note: If you don't see it, the plug-in is
not dynamically loaded, so you need to use the
-cleanparameter to restart Rational Software Architect, which will force it to load the new plug-in.
Step 3. Create a UML model
- Create a new UML Project named
- Create a new Modeling Project named
Lab2Model, as shown in Figure 12. A default diagram of the model will then open automatically.
Figure 12. Create a new UML model
- In the diagram, create a package named
- Create a new class named
Lab2Classwith the following public operations:
- If you want to see the full signature, right-click on the class, and select the options that Figure 13 shows from the context menu .
Figure 13. The Show Signature option
Step 4. Apply the Interface Inheritance design pattern to the UML model
- If you create it from the Model Explorer, drag Lab2Class into com.ibm.xtools.patterns.sample.impl from the Model Explorer. Note: If you create the class from the diagram, ignore this step.
- From the Pattern Explorer, find the Interface Inheritance pattern from the Miscellaneous Patterns category, and drag it into the diagram, as shown in Figure 14.
Figure 14. Find the Interface Inheritance pattern
- Move your mouse pointer onto the Abstract Interface
parameter of the Pattern Instance (Figure 15).
You will find two icons in the menu bar over the parameter:
- The first one will create an Interface with a dummy name that is the same as the parameter name.
- Select the second icon, and enter the
Figure 15. Applying a pattern
- Create a package named
- Drag Model2Interface into com.ibm.xtools.patterns.interfaces from the Model Explorer
- Drag Lab2Class to the Implementation Class parameter of the pattern instance. This will bind Lab2Class to the Implementation Class parameter.
- Drag Model2Interface from the Model Explorer into
the diagram to investigate the relationship.You will find:
- Model2Interface has the same public operations as Lab2Class
- Lab2Class has implemented Model2Interface. Note: If you don't see the relationship, click the free form of the diagram, select Filters > show/hide relationships..., and click OK. This will refresh the relationships in the diagram, as shown in Figure 16.
Figure 16. The complete process of applying a pattern
Step 5. Transform the model into Java code
- Right-click the Lab2Model from the Model Explorer. Note: Be sure to select the model with the icon, not the .emx file.
- Select Transform > Run Transformation > UML to Java from the context menu.
- Create a new target project named
- Select Run to execute the transformation.
- Take a look at the generated code in the Lab2Code project, which is specific to the Interface Inheritance pattern.
Maximize the value of your investment
You can see the advantage that the full tooling support of Rational Software Architect gives you for model-driven development and patterns. When you combine that with the asset-based development framework of Rational Software Architect that complements MDD, you can maximize the return on your investment of both time and money, unify the development process, accelerate the development cycle and standardize the shared assets by reusing models, patterns, and transformations.
- Model-driven and pattern-based development using Rational Software Architect, Part 1. Overview of the model-driven development paradigm with patterns: Part 1 of this series..
- Content authoring demystified (developerWorks, November 2005) is a step-by-step guide to authoring Rational Software Architect patterns and transformations.
- Learn about SOA at the New to SOA and Web services developerWorks page.
- Stay current with developerWorks technical events and Webcasts.
- IBM Rational Software Architect product page: Find technical documentation, how-to articles, education, downloads, and product information about Rational Software Architect.
- Visit IBM's Pattern Solutions and find out what IBM is doing around patterns and reusable assets.
- In the Architecture area on developerWorks, get the resources you need to advance your skills in the architecture arena.
- Browse the technology bookstore for books on these and other technical topics.
Get products and technologies
- Download a free trial version of Rational Software Architect V7.0.
- Download the Workgroups Repository.
- Rational Software Architect, Data Architect, Software Modeler, Application Developer and Web Developer forum: Ask questions about Rational Software Architect.
- Check out developerWorks blogs and get involved in the developerWorks community.
Dig deeper into Rational software on developerWorks
Get samples, articles, product docs, and community resources to help build, deploy, and manage your cloud apps.
Keep up with the best and latest technical info to help you tackle your development challenges.
Software development in the cloud. Register today to create a project.
Evaluate IBM software and solutions, and transform challenges into opportunities.