OptimalJ - Delivering on the Essence of MDA
Balancing Productivity and Flexibility
Wim Bast, Chief Architect Compuware, describes OptimalJ and how it delivers on the essence of Model Driven Architecture (MDA), to allow a balance between productivity and flexibility.
Introduction
Creating and maintaining software is extremely hard, for a number of reasons. One of the greatest obstacles is the need to combine entirely different kinds of knowledge. In a typical development project, the technical problems of design, programming, testing, and documentation are formidable enough. But the team's technical skills are irrelevant if it cannot thoroughly understand the business problems to be solved. Conversely, mastery of the business domain is useless without technical expertise.
As Grady Booch points out in his presentation The Limits of Software" (2002), the entire history of software engineering is that of the rise in levels of abstraction". The steadily climbing level of abstraction - from machine language through third-generation compilers to fourth-generation languages (4GLs) and modeling tools - has allowed developers to build bigger and more complex applications.
In the last few years, Unified Modeling Language (UML) has come to be generally accepted as the standard technique for object-oriented modeling. Dozens of products now support it, in widely varying degrees.
Model Driven Architecture (MDA) takes the next logical step towards abstraction, by applying the principle of separation of concerns. In the MDA approach, UML diagrams are used to specify applications at the level of pure business logic, without any reliance on specific Information Technology environments. This allows developers to concentrate on building complete and consistent logical model of the business domain, without having to think about how the software will eventually be implemented.
By implementing MDA, OptimalJ provides all the benefits that have been accorded to MDA by the Object Management Group (OMG). OptimalJ allows you to model a business domain and generate most of an application's repetitive code, through a set of automated transformations and rules; and to do all of this in an agile development environment. OptimalJ's strength rests on five cornerstones:
- Model Driven Development (MDD)
- Business rules
- Patterns
- Active synchronization
- Integrated deployment
Since the 1950s, source code has been automatically transformed into object code by compilers. MDD, as implemented by OptimalJ, adds two further levels of transformation:
- Business Model to Architecture Model
- Architecture Model to Code Model (source code)

Figure 1: The MDA Approach
To start with, business logic and data structures are identified and used to create a business Model - in MDA terms, a Platform Independent Model (PIM). As its name implies, a PIM contains no dependencies on hardware, operating system, programming language, or middleware. The business Model is then translated into an Architecture Model - in MDA terms, a Platform Specific Model (PSM) - which is optimized for a particular runtime environment. Finally, the Architecture Model is used to generate the application's source code, which is referred to as the Code Model.
MDD allows an application's business model(s) to remain stable and evolve smoothly, unperturbed by any changes in hardware platforms, operating systems, programming languages, databases, or middleware. The core concept is to model at a higher level of abstraction.
Business Rules
Managers and other employees tend to think of business processes in the form of rules. For instance, "The balance at month end is computed as the balance plus interest compounded at the monthly rate". However, it has not always been easy to incorporate these rules into reliably running software.
With OptimalJ, developers can specify business rules as part of the domain model. OptimalJ then translates these rules into a working J2EE application, automatically propagating them to the appropriate points in the application.
In the JSP-based presentation tier, for example, a checking account number might be validated for proper formatting, while a business rule that enforces account number uniqueness is implemented in the EJB-based business logic tier. This saves developers from having to implement the same business rules throughout the code. Moreover, they can quickly satisfy requests for change by tweaking the appropriate business rules at the model level. Patterns
Writing source code by hand is repetitive, error-prone, and inefficient. As far as possible, decisions and constraints should be stated only once, and automatically replicated thereafter. This can be done using patterns; a powerful concept popularized by the book Design Patterns. A pattern is a common solution to a common problem in a given context. In other words, it is a practical way of reusing software ideas rather than actual code.
While patterns can be used in conjunction with manual programming, they can be applied more consistently and reliably through automation; and this is what OptimalJ does. Technology Patterns are used to map elements of a Business Model to elements of an Architecture Model:

Figure 2: Technology (Design) Patterns help to map from Business Model to Architecture Model
Implementation Patterns perform a similar task in mapping from the Architecture Model to the Code Model:

Figure 3: Implementation (Code) Patterns help to map from Architecture Model to Code Model
Whenever possible, decisions are made once, in a single place (for example: date/number formats, Cascading Style Sheets, data validation, etc.) As in the case of business rules, these properties are automatically propagated throughout the application's code.
OptimalJ does not use patterns ad hoc or haphazardly, but blends and embeds them into a complete and consistent application framework. The OptimalJ Architecture Edition allows new models and patterns to be plugged in, giving a company full control of the application framework it uses.
Sun has validated OptimalJ's use of the Sun Core J2EE Patterns, confirming that their usage is fully compliant with Sun's J2EE Pattern Catalog. For instance, OptimalJ patterns provide Business Facade objects to front-end EJBs, and ensure that components default to a coarse-grained style of communication, in order to maximize distributed performance. Active Synchronization
There are three main types of modeling tools:
- Drawing tools, disconnected from the source code (like Microsoft Visio)
- Products that offer models as an alternative view of source code (like Borland Together, IBM Rational XDE, and Omondo EclipseUML)
- True modeling tools that create and maintain models, and can then generate code from them (like OptimalJ and other products based on MDA)
OptimalJ differs fundamentally from "in-sync" modeling tools such as Borland Together. In that it lets developers work with business models in the complete absence of code, as opposed to being tightly coupled to the underlying source code. Code generation is reserved to the stage where the application is logically complete, thus allowing developers to test the system.
At the code level, an OptimalJ application consists of three parts:
- A set of generic, static application frameworks - for instance, the popular open-source Struts framework for the Web layer
- A dynamic, specific application framework that is generated from the Architecture Models via Implementation Patterns
- Code that is added manually by developer
The first and second types of code, automatically added or generated by OptimalJ, are placed within guarded blocks that cannot be edited by hand. The third type of code, written by developers, is placed within free blocks that OptimalJ does not change or overwrite when generating code.
Integrated Deployment
While compiling an application, OptimalJ automatically packs the components for each tier into separate archive files, together with the necessary deployment descriptors. It even creates special database archive files; although these are not required by the J2EE specification, they help to save time. Deployment can be configured for a specific J2EE application server, such as Sun Java System Application Server, OracleAS, IBM WebSphere, or BEA WebLogic.
OptimalJ's built-in, lightweight, single-user test environment lets developers test their applications instantly, without complex configuration and deployment. The test environment includes the JBoss open-source EJB server, the Tomcat Web Server and Servlet Engine, and the Solid DBMS.
Benchmark Results
It is notoriously difficult to obtain precise, objective comparisons of the value of alternative IT techniques. Even run-time performance benchmarks can be slippery; measuring development productivity is even more challenging. Nevertheless, it is worth an effort failing which potential adopters can be thrown back on word of mouth and anecdotal impressions.
The Middleware Company (TMC), which has considerable experience in this field, set up a painstakingly fair experiment to find out how MDA compared with state-of-the-art conventional programming. Two teams of experienced developers were assigned an identical task: to build an implementation of TMC's J2EE PetStore specification, using EJBs. One team used Compuware OptimalJ, the other a leading integrated development environment (IDE).
The result of the experiment - the IDE team finished in 507 hours, while the MDA team took 330 hours - 35% less time. Furthermore, the MDA team's application was error-free, whereas the IDE team's application had several bugs. While the IDE team was already familiar with the IDE used, the MDA team had never used MDA before and had just a few days to get used to OptimalJ.
What makes this result still more impressive is that even MDA advocates do not usually claim great benefits in the initial development phase. Rather, they expect the biggest gains to accumulate over time, in the course of maintenance and subsequent releases.
In a subsequent follow-up study, with the same teams and new releases of the same tools, TMC found that OptimalJ enabled a given set of major enhancements to be made 37% faster than the conventional IDE. Conclusions
OptimalJ strikes an ideal balance between productivity and flexibility. For routine tasks, its built-in patterns and frameworks allow highly optimized code to be generated without human intervention. With a little experience, these patterns can also be tweaked or extended - or new ones added - at any given time. Meanwhile, analysts and designers are freed up to devote their full attention to the domain model, thus ensuring that business logic and information are correctly represented. Reference
- For more information about Compuware OptimalJ and MDA, become a member of the JavaCentral community site.



