GRC
HR
SCM
CRM
BI


Article

 

How Do You Get a Picture of Your Development Project? UML Modeling with Together Edition for SAP NetWeaver Developer Studio

by Karl Kessler | SAPinsider

January 1, 2005

by Karl Kessler, SAP AG SAPinsider - 2005 (Volume 6), January (Issue 1)
 



Karl Kessler,
SAP AG

If you're following best practices in developing and designing your applications, you're putting some effort into modeling your projects based on your requirements. Proper modeling saves time, reduces errors, effectively communicates your projects to other stakeholders, and even provides long-term documentation for other teams down the road. But are you modeling in the most effective way possible?

When working in Java, SAP NetWeaver Developer Studio is the integrated tool set for any applications designed for SAP NetWeaver and running on SAP Web Application Server. SAP NetWeaver Developer Studio supports a variety of ways to design these programs, each with its own approach to modeling the resulting application:

  • J2EE — SAP adheres to open standards, and supports J2EE version 1.3. From SAP NetWeaver Developer Studio, you can develop a J2EE-compliant application using wizards for servlets and JSPs, and all kinds of Enterprise JavaBeans (session beans, entity beans), each with its own flavor. In SAP NetWeaver Developer Studio, a graphical display shows all J2EE elements in a diagram that you can use to start editing or to maintain relationships between the J2EE elements.

  • Web Dynpro — J2EE cannot solve some inherent problems common in business applications, so SAP also offers higher-order frameworks such as Web Dynpro that dramatically reduce development time, transforming your development work from pure coding to a more model-oriented approach. As a result, the whole user interface is modeled with graphical tools, from layout with controls to management of navigation and data flow.

  • Web services — On the business logic level are Web services, which are well suited to integration with external systems. Web services map nicely into Web Dynpro, but can be used independently of the user interface.

But before you actually dive into the details of J2EE, Web Dynpro, or Web services, you must consider the overall architecture of your application. This is where UML1 comes into play — especially the larger your project is. Indeed, when creating the SAP Web Dynpro project — both runtime and designtime — SAP's own developers used UML diagrams to model Web Dynpro in a platform-independent way. Both the Java implementation (released with SAP NetWeaver 2004) and the ABAP implementation (planned for the subsequent SAP NetWeaver release) are derived from the original UML model.

Why UML? It offers some important benefits compared to traditional modeling approaches. First, UML is the standard for software modeling and provides a standardized language to express various aspects of the system to be implemented. Standardization helps avoid human error when sharing project information — errors that developers readily admit are quite common, especially in the early phases of a major development project.

The standardized language and graphical notation of UML also supports discussion of architectural aspects much better than a textual representation. What's more, UML is the starting point for roundtrip engineering, meaning you start with the model, but can then automatically generate code, change the code, revisit the model, and so on.

Although SAP NetWeaver Developer Studio offers highly graphical tools that are heavily model- rather than code-driven, it has no direct support for UML. Fortunately, the architecture of the Studio and its underlying Eclipse foundation2 (see Figure 1) has the flexibility to integrate a UML tool.

UML As a Basis for Modeling

Most Java developers are familiar with UML (Unified Modeling Language). UML supports various layers of modeling, from a high-level view to fine-grained class diagrams that are one step away from coding your project.

In UML, you typically express the basic functionality of an application or system with a use case diagram. This diagram shows the functions a system offers and its actors (e.g., end users) in order to model the high-level requirements of a system.

Sequence diagrams focus on the dynamic interaction (flow of control) between different objects. They model what messages transfer control from one object to the other. At times it may also be useful to model the object's potential states in state transition diagrams.

Class diagrams are more low-level and closer to the actual implementation. Class diagrams depict classes as boxes with the attributes contained therein. Relationships between classes (inheritance, interface implementation) are shown as arrows pointing from one class to another. Class diagrams can serve as a starting point to generate class skeleton code.

NOTE: In this article, we look specifically at diagrams that model static aspects of a system and its implementation. The full UML specification offers many more diagrams. See www.UML.org for more details.


Figure 1
SAP NetWeaver Developer Studio: Software Layers

As you can see in Figure 1, the various tool sets and perspectives from SAP are not built directly on top of the Eclipse foundation. Instead, a modeling layer (originally developed jointly by SAP and Borland, an SAP Software Partner) resides in between. This layer abstracts these SAP tools and perspectives from physical Eclipse resources, and offers a modeling environment that comes with highly graphical tools. The modeling layer is used both in SAP's Web Dynpro and J2EE tools.

On top of this same modeling layer Borland now offers tools for UML modeling, documentation generation, and metrics that fit very nicely into the technical architecture of the Developer Studio — SAP Together Edition for SAP NetWeaver Developer Studio.

This complements the portfolio of the Developer Studio with helpful features such as:

  • Patterns and templates for speeding up development time

  • Source code checks for improved quality assurance

  • Ongoing support for documentation

  • Sharing of insight into development projects by exporting and importing models

The nature of Eclipse allows you to add the Together Edition plug-in seamlessly into Developer Studio. You can easily switch between the perspective offered by SAP and the UML modeling perspective offered by Borland, and, of course, combine the views delivered by SAP and Borland to your custom perspectives.

To execute model-driven development for analysis, design, and implementation, Together Edition supplies all standard UML diagram types: use case, activity, state, class, sequence, collaboration, deployment, and component diagrams.3 The diagrams are stored as individual files in the file system and are versioned using the incorporated version control system. Even individual design elements can be stored as separate files. In this way, the lock level for the stakeholders involved can be set very specifically.

All the delivered diagrams support various phases of analysis and design; however, the strengths of Together Edition lie in its source code-based diagrams — classes and sequence diagrams.

Building UML Class and Sequence Diagrams from SAP NetWeaver Developer Studio

In the case of class diagrams, Together Edition for SAP NetWeaver Developer Studio determines all the information directly from the sources, without having to store metadata in other (diagram) files. This is in keeping with Together's focus on "Synchronous Roundtrip Engineering" — changes in the sources are displayed immediately in the diagrams, and changes in the class diagram are displayed in the sources, without any detour.

Once you have opened a new UML modeling project, you can switch immediately to the diagram view. In the upper half of Figure 2 you see classes and interfaces represented as nodes, and the relationships between classes and interfaces are clearly shown. You can easily create new items using the palette on the left. Then, all changes you make to the diagram are immediately reflected in the code window below, so the model stays in sync. Similarly, if you change a class's name in the code window, the change appears immediately in the diagram. This full roundtrip engineering is a particular strength of Together Edition; it is also helpful for reverse-engineering any existing code base by providing graphical views of your sources and allowing you to navigate through them. When you click on a graphical item in the class diagram, the corresponding position is highlighted in the source code.

Figure 2
Class Diagram

You can also use sequence diagrams to generate code. Although sequence diagrams are not entirely synchronous, it is possible to work with them "almost synchronously" forward and backward — generating source code from sequence diagrams and generating sequence diagrams from source code.

The sequence diagram looks something like a swim lane diagram, where each lane represents the responsibility of an object of a given class. This diagram shows the flow of control once an action is triggered by the end user. In the typical proceeding of model-driven development, you reach this point when you want to model the technical behavior of each use case.

Figure 3 displays the actor (end user) on the left and the objects distributed among several lanes. Control is handed over via message invocation from the actor to one of the objects; this object in turn passes control to another object, and so forth.

Figure 3
Generating Implementation for a sequence Diagram

Class and sequence diagrams work hand in hand. If you want to know how a function of one of your existing sources has been implemented, you can simply select the "Generate Sequence Diagram" function directly from your class diagram. The resulting sequence diagram saves time by documenting the behavior of the functions in your current application.

Additional Benefits and Functionality

UML modeling with Together Edition also allows you to:

Quickly Define and Use Patterns and Templates
Patterns and templates accelerate design and implementation by providing prefabricated source text that helps solve common design problems. Together Edition supports the well-known "Gang of Four" patterns (Singleton, Factory, Memento, Observer, and so on), as well as patterns from other areas such as J2EE and TagLibs. These patterns provide you with the option of recognizing frequent code patterns in a project and storing them as templates. When you create your own patterns, Together links you to the resources of Apache Velocity,4 a powerful open-source template engine that allows you to use complex variables, conditions, and control elements in source code templates.

Figure 4 shows a list of supported patterns along with details of the "Factory Method" pattern. Once you have selected a pattern, Together Edition instantiates the pattern in your current UML project, directly generating all the necessary source code and class diagrams automatically for you. By consistently applying patterns, you can achieve much improved productivity and knowledge transfer.

Figure 4
Applying a Pattern

Improve Quality Assurance for Your Source Code
With the metrics calculation function, Together Edition enables each designer, architect, and developer — at any time during the development cycle — to check class design features such as inheritance level, excessive dependencies, cohesion, encapsulation, and polymorphism. In addition, audits enable you to check whether the source code is in keeping with conventions that keep maintainability, readability, and changeability at a high level. (See Figure 5.)

Figure 5
Quality Assurance Features: Metrics and Audits

For example, the Inheritance metric measures how deep the inheritance hierarchy of your project is. If it is too high (i.e., too many inheritance levels), it's a sign that your implementation design is probably weak and that reworking and refactoring will be required as soon as your project goes into production.

Source code auditing approves several quality aspects of the code, providing details such as found duplicate code, proper use of arrays and reference, critical errors such as misused inheritance, and bad maintainability symptomatic of "shotgun surgery."5 Metrics and audits provide you with the necessary information to improve and retool your code base.

Generate Documentation for Users Inside and Outside the Project Team
To create synchronous documentation from a project at any time, Together Edition provides the option of generating HTML documentation. Within this platform-independent documentation, the users — even those without access to Developer Studio — can navigate through the project. Ideally you would generate the documentation to a directory on your intranet, where other stakeholders can access it via their browser.

In Figure 6 you see the HTML-based UML documentation opened in a browser. You can navigate through the model tree in the lower left frame. By clicking on an element, you open a diagram and the corresponding documentation is shown below it in JavaDoc format.

XMI Support
Suppose you work with other colleagues in offshore locations that must view and understand your implementation design. To communicate with other UML tools, Together Edition also provides an import and export function using a version of XML called XMI (XML-Based Metadata Interchange), which is the standard for exchanging models with other environments. You can export your model and choose from different XMI versions. The XMI import function also recognizes several "dialects" of XMI.

Note!
  A further extension, in the form of a plug-in for XMI export of your model, is required to subsequently import XMI into Web Dynpro modules.

In a typical scenario, if you have modeled your classes and want to generate the corresponding Web Dynpro stubs from them, then you export your model to XMI and feed the Web Dynpro Generator with this XMI file.

Conclusion

This brief overview gives just a taste of the range of functions that the Together plug-in offers. In addition to bringing the benefits of UML to your SAP NetWeaver Developer Studio projects, Together is fully integrated in the Eclipse-based environment and behaves fully and entirely in an Eclipse-conformant manner, to keep the learning curve as flat for all users — developers and other stakeholders — as possible.

For more on the Together plug-in, please visit http://info.borland.com/techpubs/together/tsap62/viewordownloadgsg.html. In the future, look for SAP and Borland seminars for detailed information on how to use Together Edition for SAP NetWeaver Developer Studio.

The author would like to thank Markus Hebach from Borland for his help in the writing of this article. Markus Hebach is Senior Technology Consultant at Borland GmbH in Germany and focuses on the Together product line in the areas of consulting, presales, and training.


1 Unified Modeling Language (see www.uml.org).

2 Eclipse is an open-source, Java-based development platform. See www.eclipse.org.

3 These adhere to the UML 1.4 standard. Together also supports the UML 2.0 standard. When you activate the UML 2.0 profile for a project, a "collaboration 2.0" diagram is available, and certain properties of the diagrams are extended to meet the UML 2.0 specification

.4 See http://jakarta.apache.org/velocity/index.html

5 This term — an indicator of bad design when one change leads to other small changes throughout your project — was famously coined by Martin Fowler in his book Refactoring.


Karl Kessler joined SAP in 1992. He is the Product Manager of the SAP NetWeaver foundation, including SAP Web Application Server, Web Dynpro, ABAP Workbench, and SAP NetWeaver Developer Studio, and is responsible for all rollout activities. You can reach him via email at karl.kessler@sap.com.

An email has been sent to:






More from SAPinsider



COMMENTS

Please log in to post a comment.

No comments have been submitted on this article. Be the first to comment!


SAPinsider
FAQ