I don't like MDD but like UML - why should I use MDD if I think it is useless ?

527 views Asked by At

I am a java software developer/architect and I like UML.

Saying that I also hate the java generated code.

I don't see any value trying to generate the skeleton of my application:

  • creating empty classes is really easy and I don't need a tool to do that
  • also I cannot reuse the generated code because the way it is generated makes it impossible to reuse

The dilemma for me is that my requirements changed so quickly that I need to be able to implement the new demand immediately into an existing code.

My problem is that if I generate my code from my model and then manually develop inside the generated codebase, I cannot generate code again using a model because my modification would be erased.

Except I copy/paste the changes back and forth. That is an enormous effort for too few results. Therefore I do not use MDD but still use a lot UML.

Could UML be successful in a project without MDD code generation ?

I am asking this question because I have a new boss who wants to introduce full MDD process with IBM RSA and today I prefer to have live code and model synchronization or merge with Omondo.

  • Why change a running and proven system?
  • Why systematically generate code from a model while I can do it directly in the code and just merge it later with the model?
  • Why get crap database code generation which cannot even be deployed while I can add stereotype in order to get java annotation and use them with hibernate to generate my database?

One of the reason for boss's change is to get a better project documentation in HTML format. I highly doubt this and think he is looking for more control on delivery and does not know what else to invent!

Other argumentative reasons:

  • Use a product from a large and stable company.
  • Have a full model available which could be deployed in any other language.
    (This is why for me MDD is stupid because it is impossible to deploy on any platform any server, any database just from a model. So why to waste my time?)

Please give me some arguments in order to come back at next meeting and crash this stupid new MDD fan who wants to reorganize the way we work today!

3

There are 3 answers

2
sfinnie On

I think your post has the answer in it.

MDD has been plagued with 2 fundamental problems:

  1. An input (modelling language) that is insufficiently expressive to capture the entire problem. Result: you need to complete the specification with another language (code).
  2. The generators - i.e. the rules that convert models to code - are generally incomplete and/or not open for modification by the development team and/or generate poor quality code.

Put those two things together and you get the horrible mess you mention. Consequence: trying to splice together hand-written code with poor-quality generated code. Result: not pretty.

However. Please don't surmise from above that I'm anti-MDD. I'm not - in fact the opposite is true. BUT: the tooling and process need to address the two fundamental issues above.

I've come across /very/ few that do. I used RSA several years ago and it definitely wasn't one of them. (However it's had the intervening time to improve, so it may be there now).

A simple "temperature check" question is to ask whether the tool provides a full Action Language. If it doesn't, it'll fall foul of problem (1). If it fails that, chances are you're in for pain.

If all your boss really wants is good HTML documentation, then simply integrate UMLGraph or apiviz into your build.

So to answer your specific question:

Can UML be used successfully without MDD? Yes. Generally in two ways:

  1. As an informal or semi-formal notation for whiteboard sketching while figuring out the problem and/or solution (what Martin Fowler calls UML as Sketch)
  2. As auto-generated documentation from the code as part of the build process.

Where you'll end up burning unproductive time is creating formal UML diagrams (often with an expensive tool) that have no direct link to the code.

hth.

3
Gabriel Ščerbák On

If you cannot control the generation, you are probably using the wrong tools.

What you generate - skeletons or framework specific code - is also depending on the tool. Use tools which allow you to create your own templates.

It is wrong to assume roundtrip engineering will ever work. You cannot transform less detailed model to more detailed code and then back without losing information. One way to solve this would be having same level of details in models as in code, which is not a great thing.

Better approach is to use one way generation from models combined with some good practices for combinening generated and manually written code.

You can use protected regions for manually written code:

  • you specify in template places - e.g. method bodies, which should be not overwritten when regenerating

Or the generation gap pattern:

  • you generate abstract classes and code using skeletons of concrete classes, which you complete manually).

There is still one other way to approach this - full code generation.

It might look similar to the bad practice of coding using models, but the point is to specialize for generating certain kind of applications - web apps, embedded apps. What you generate is then basically a framework specific code, which can be often expressed and maintained using models.

Don't forget, that modeling is not just about diagrams, you can use textual DSLs as well.

To your question - UML was not originally ment for MDD (many MDD practicioners don't use UML at all...), so you can use it for OO analysis and design as you like.

When it comes to your boss and RSA, try to find out what your boss really needs and wants, then try to provide him some better tools or practices.

As mentioned in the other answer, there are many tools for documentation.

0
Volker Stolz On

With MDD, making changes to the design hopefully becomes cheaper: if the requirements change, in your approach you have to update the UML-based documentation, and the code. Now, if the code could be automatically generated, the changes to the code should follow automatically from the changes to the model, and you wouldn't have to do it manually (at least in those places where you don't add new stuff or need to change the business logic).

Assuming that MDD works (yeah, right ;), could you justify the double cost of maintaining the model (for documentation and design), and the code?

One argument in your favour could be that if the project isn't too big (whatever that means), that it's not worth having all the overhead.