Sie sind auf Seite 1von 8

Model-Driven Development

without MDA
A lightweight approach to MDD

Javier Paniza

Introduction
A notable problem of Java Enterprise Development is its inherent complexity.
Either if you use Java EE standard or Spring, your development team will never
be as productive as a VisualBasic, PHP, Ruby&Rails, 4GL or even COBOL
development team. Complexity of Java Enterprise requires very skilled
developers, moreover these developers need to write a lot of code.

The ideal solution for this problem could be the Model-Driven Development
approach. Basically MDD states that just the model part of an application has to
be developed, and the rest of the application will be generated from this model. In
this way, the developers write less and simpler code, nevertheless a powerful
Java Enterprise Application is created.

However, for today, the MDD usage is still very complex. It's needed to make a
big investment of time, expertise, and tooling; usually building your own DSL's
and combining them into a software factory, and it costs a lot of effort. Therefore,
only big companies can afford MDD, and it can only be paid back when using it
multiple times for different projects. And, of course, MDD is a hard alternative for
mid-size and small companies.

Fortunately you can enjoy the goodness of MDD without its pains. Just removing
MDA, DSLs, UML and code generation from MDD and you'll obtain a simple but
effective way to do Model Driven Development.

This white paper will examine how to do Model Driven Development in a


lightweight way, so it could be affordable for small and mid-size companies, and
cheaper for the big ones.

The sin of Java


Definitely Java is the ubiquitous platform for enterprise development. Objective
data says it. For example, a simple search in a search job engine 1 shows the next
results: 8,655 for Java; 2,167 for VB; 1,654 for C#; 1,548 for PHP; 1,385 for C++;
659 Ruby and 645 for Cobol. The advantage of Java is overwhelming:

1 www.careerbuilder.com - October 2008

Model-Driven Development without MDA Page 1


Jobs by language
10000

9000

8000
Java
7000 VB
C#
6000 PHP
C++
5000 Ruby
Cobol
4000

3000

2000

1000

Either as a cause or as an effect of this popularity Java is now perfectly adapted


for enterprise development. It runs in every operating system, against any
database, it can connect to any enterprise system (queue message systems,
ERP, mainframes, etc). Java applications run on scalable and transactional
application servers. A lot of high quality development tools and frameworks are
available. And all this come not only from the big agents of the IT industry, such
as IBM, Oracle, Sun, etc, but also from the open source community.

But the Java world is not so wonderful. The little sin of Java technology for
enterprise is its complexity. It's not easy to have something powerful and flexible,
and simple and easy at once. Although big efforts have been done to simplify
Enterprise Java, it is still very complex. Note the Richard Monson-Haefel's
comment about Java 5 EE 2 3:

“Although JEE 5 is somewhat similar to previous versions, the simplification is not


enough. Ease of development has been ignored in favour of breadth of
functionality and flexibility”

The Model-Driven Development promise


In the fight against Java Enterprise complexity, during last years, a new and
promising approach for development has arisen. It is Model-Driven Development.
As wikipedia says MDD “focuses on creating models, or abstractions of
something more tangible, that describe the elements of a system. It is meant to
increase productivity...” 4. The idea is brilliant, you write only the model and from
this one you obtain the complete application.

OMG produces a concrete incarnation of this idea in 2001, called Model-Driven


Architecture5, since that moment a lot of implementations of MDA and other MDD

2 Richard Monson-Haefel: It's too late to save Java EE: http://www.infoq.com/news/Java-EE-


Demise-Report
3 Is Java EE 5 lightweight enough?: http://www.infoq.com/news/Java-EE-5-light-enough
4 Model-Driven definition on wikipedia: http://en.wikipedia.org/wiki/Model-driven_development
5 MDA official site: http://www.omg.org/mda/

Model-Driven Development without MDA Page 2


solutions have been produced by commercial vendors and open source
community6.

The invariable promise of MDD is complexity reduction, for example an IBM white
paper7 says about MDD:

“Using ... Model-Driven Development (MDD) ... allows architectural decisions to


be captured explicitly and encoded in the system with automation. And by using
patterns and MDD, complexity can be reduced in the work, enabling on demand
design and development.”

Does MDD fulfill its promise?

Model-Driven Development drawbacks


Really dramatic improvements in productivity and maintainability can be achieved
by using MDD, but though this is true, we have to be shrewd and examine the
cost and limitations, asking: How much does it cost to start with MDD? Can you
be agile using MDD?

Is MDD cheap?
Let's examine the most popular MDD incarnation, MDA. The idea behind MDA is
explained in its official site in this way8:

“MDA starts with a Platform-Independent Model (PIM) of an application's


business functionality and behavior, constructed using a modeling language
based on OMG's MetaObject Facility (MOF). .. MDA development tools convert
the PIM first to a Platform-Specific Model (PSM) and then to a working
implementation on virtually any middleware platform”

So, you have 3 steps, develop a PIM, transform it to a PSM and then transform to
the final implementation. Undoubtedly, it is a more complex approach to software
development than the agile one: “write code, obtain product”. More complexity
involves more tools (to learn, or to develop) and skilled people in these tools and
technology; and also it's difficult to find developers with ability in MOF, PIM, PSM
and all this MDA stuff 9.

A popular alternative to MDA is to use Domain-Specific Languages. In this way, a


custom language adapted to the domain is developed. For example, it's typical to
create several DSLs10 as:

• Business Object DSL


• Rich Internet Forms DSL

6 OptimalJ, AndroMDA, openMDX, etc.


7 Combine Patterns and Modeling to Implement Architecture-Driven Development:
http://whitepapers.techrepublic.com.com/abstract.aspx?docid=355980
8 MDA Overview: http://www.omg.org/mda/specs.htm#MDAGuide
9 Are You Ready For the MDA?: http://www.agilemodeling.com/essays/readyForMDA.htm
10 8 Reasons Why Model-Driven Approaches (will) Fail: http://www.infoq.com/articles/8-reasons-
why-MDE-fails

Model-Driven Development without MDA Page 3


• Microflow DSL
• Business Rules DSL
• Services DSL
• Security DSL

This way could be simpler than using MDA, but it's not cheaper because you
have to design the languages and to develop the transformation and code
generation tools, obviously this is costly in money and time. Moreover, standard
tools to work with these languages (as editor or debugger) are not available.

Of course, MDD is not cheap and, in consequence it's out of the scope of mid-
size and small companies, and even large companies need to reuse their MDD
assets several times in order to obtain the return of the inversion.

Fortunately, a simpler way for using the Model-Driven idea has been developed
and used by part of the “developers community” in the last years. This lightweight
model-driven development allows to use the already available tools, language
and developers to do MDD with all its productivity, but with no extra cost.

Is MDD agile?
“Let me change this. That doesn't look right; let me change it again. That's better”

The above sentence has the essence of the “Agile Development”. We have not a
carefully upfront design, defined sequential steps (analysis, design, programming,
testing, etc), abundant documentation, well defined roles (analyst, programmer,
tester, etc), etc. Nothing of that. Instead we have an executable product, albeit
simple at first, and we change and release it frequently.

Agile methods have become very popular nowadays 11. In order to be used a
“development technology” must allow you to do changes and see the effect of the
changes fast. Is MDD ready for that?

In MDD you have models (UML, DSLs) that generate code. If a change is
required, like a class refactoring, you need to change the model and to
regenerate code. Also it's typical to touch the generated code in order to achieve
the desired changes. That is, you need time and effort to do changes even using
a good round trip tool.

With agile methods we try to achieve a creative process around the executable
product and with the direct user feedback. If the developer has to wait several
minutes to do an incremental change and see the result of it, then the
concentration is broken, and the creative process is disrupted 12.

Is it possible to be agile with MDD? Of course. But code generation and using two
types of artifacts (DSL/UML and Java) do not help. Nevertheless, we can remove
DSL and code generation and still use MDD and be more agile at once.

11 Agile Alliance: http://www.agilealliance.org/


12 Look at the books by Mihaly Csikszentmihalyi

Model-Driven Development without MDA Page 4


The Old Dream of Object-Oriented Programming
Really, the original idea of model-driven software started in 1967, thanks to the
first OO language Simula 67. Using Simula 67 it was natural to create software
that simulates real life systems, thanks to classes, objects, inheritance and
polymorphism. Creating software concentrating in the model was already
possible.

In spite of the proliferation of OO languages in the 1980s, the OO was not


commonly used in mainstream software application development until the 1990s.
This was a good chance to simplify the business software development because
it was possible just define the business concepts, as invoice, customer, delivery,
order. etc in order to develop an application.

However, creating business applications in the 1990s using OOP was not so
easy. A lot of things as CORBA, EJB, MVC or UI development added complexity
to OO development.

In the 2000s Model-Driven Development arose as an idea to simplify all this, but it
still has its own complexity.

However, in the mid-2000s several frameworks emerged from open source


community. This new frameworks convert in a reality the naïve idea behind OO,
just defining the classes for the concepts of your application, and get the
application running. We can name these frameworks “Lightweight Model-Driven
Frameworks”.

Lightweight Model-Driven Frameworks


A Lightweight Model-Driven Framework allows to develop applications defining
only the model part of the application and all the rest is provided by the
framework. For defining the model part simple Java classes with Java 5
annotations are used.

This way, writing Java classes for Invoice, Customer, Product, Order, etc. with the
appropriate metadata is enough to obtain a working application. The user
interface, database access, behavior for common task and so on are done

Model-Driven Development without MDA Page 5


automatically by the framework.

Lightweight Model-Driven Frameworks do not use UML, DSL and code


generation.

Benefits of Lightweight Model-Driven Frameworks


Using a good Lightweight Model-Driven Frameworks you will:

● Reduce cost, because you can concentrate in the logic of your application,
not in developing DSLs, code generators and so on. You can be
productive from the first day.

● Simplify code maintenance, because you have less code.

● Maximize the chance to be agile, because:

○ Fewer steps are needed to write the code to obtain the running
application.

○ The time from the beginning to a working application is short.

● Obtain richer applications, because usually the LMD frameworks are very
optimized and produces high quality applications.

● Migrate already existing code, because they use Java classes with Java
standard annotations, and not proprietary DSLs, a big part of our current
code is already ready to be used with a LMD.

● Delivery our current developers skills, because the core of the application
is plain Java classes.

● Use the already existing tools for Java development.

High productivity of MDD with low cost: Possible for small companies, cheaper
for the bigger ones.

What to Look for in a Lightweight Model-Driven Framework


When looking for a Lightweight Model-Driven Framework be sure to consider the
following requirements:

Be sure that it is Lightweight: The core of the application must be simple Java
classes (POJOs). It must not require UML. It must not use DSLs or code
generation. Most part of the application, including the User Interface, has to be
provided automatically.

Standard Java: Look for a solution that uses standard Java for the source code,

Model-Driven Development without MDA Page 6


as JPA for persistence; and also for the resulting application, supporting not only
the classic application servers but also Java Portal Servers (like WebSphere
Portal, Liferay or JetSpeed).

Application shape: To enjoy all benefits of LMDF, seek a framework whose


resulting application will be close to your required one. Moreover you need a
framework flexible enough to fit to your concrete necessities, this can be achieved
being customizable and open source.

Customizable: Seek a framework customizable enough to face up special cases


in your application. Can you create your own custom UI for special cases? Can
you define your visual control for your own data types, or change the default
ones?

Open Source: The ideal solution should be open source in order to obtain a
better flexibility. Can you improve the code of the framework and contribute back?
Does the project accept contributions in a shared intellectual property way? Does
its license allow you to develop commercial applications?

Mature project: Look for a project with several years since its first stable version,
at least 50.000 downloads, active public forums (100 messages/month),
exhaustive documentation in several languages (not just in English), etc.

OpenXava
OpenXava is a mature Lightweight Model-Driven Framework focused on
productivity and flexibility. It allows developers to write less and simpler code, but
at the same time it is flexible enough to face any case you can find in a business
application.

This effectiveness is possible because OpenXava has been used and refined for
years to create enterprise applications with Java just by the same developers that
use it. In fact, it's a LGPL (so it's possible to create commercial applications)
project with more than 30 contributors around the world and an active and
growing community.

OpenXava provides the following advantages:

● Java Persistence API: The core of the OpenXava applications are


standard JPA Entities. Given that is the industry standard for modeling
business logic and database access, your application code will be a safe
investment.

● User friendly interface: Although the user interface is generated


automatically from the model classes; in OpenXava the user interface is
not a mere mirror of object model, but it is usable and familiar from the
user viewpoint.

● AJAX portlets: OpenXava produces AJAX applications that can be


deployed in any JSR-168 portal server, as Liferay, JetSpeed or IBM
WebSphere Portal. Of course, you can also run OpenXava applications in

Model-Driven Development without MDA Page 7


any J2EE or Java EE application server, even in a simple servlet container
(like Tomcat).

To find out more about OpenXava visit www.openxava.org.

Model-Driven Development without MDA Page 8

Das könnte Ihnen auch gefallen