r/programming • u/softmodeling • Jan 19 '11
Executable UML standards - "programming" with UML
http://modeling-languages.com/blog/content/new-executable-uml-standards-fuml-and-alf19
u/quanticle Jan 19 '11
Oh dear god, not this again. I mean we've had this promise of, "We can generate running programs directly from diagrams," for more than twenty years now. First it was the CASE tools of the Eighties, then Rational tried it with Rational Rose, and now this.
In every case so far, the tool works great as long as your logic is simple and your relations are straightforward. Unfortunately, the only projects where those conditions apply are either in classrooms or tech. demos. Once you start trying to generate executable code for applications that have complex multi-way relations or complex business logic, the executable code has always turned to be harder to maintain in the long run.
I worked for a company that tried to move to a more formal methodology. There was a huge project to put all the data model classes and their relations into UML diagrams and feed those diagrams into Rational Rose. From that point on, developers were not supposed to modify modeled classes directly, but rather update the Rose model, which would then autogenerate the code.
It might have worked for a couple of years, but by the time I got there, pretty much everyone had acknowledged that the attempt to put everything into Rose was an unmitigated disaster. The classes generated were obtuse and hard to use. Code generation from the model took an hour. Everything seemed to be much more difficult than it should have been. Piled on top of this was the fact that the egregiously long generation times perverted incentives for the developers. A developer was more likely to abuse an existing model class to hold new data rather than modify or create a new class. Why? It was literally easier and faster (in terms of development time) to take an "almost right" class and add functionality to it via reflection than it was to just go ahead and create a new class with the necessary functions.
At the time I joined, the company was in the midst of a multi-year project to strip out all of the Rational Rose classes and replace them with hand-made classes that would do the same things, but be easier to use and modify.
tl;dr "Executable diagrams" are a trap for any nontrivial project. They look good, but will turn your code into spaghetti.
2
2
Jan 19 '11
I used Rational Rose with quite a bit of success. But there were some notable differences:
We used two-way generation. If we added or altered a class in code the UML diagrams would automatically update themselves.
It was used only as a modeling and design tool, not a programming tool.
We were using Visual Basic 6, which meant that UML could actually represent everything the language could do. I cannot think of any other OOP language that is limited enough to be described by UML.
4
u/quanticle Jan 19 '11
It was used only as a modeling and design tool, not a programming tool.
That's the big mistake that managers often make with these tools. The models and diagrams look so precise. And, in theory, they would be. In practice, however, the models aren't nearly as precise as they claim to be, and what happens is that the team just ends up delegating a lot of its decision making responsibilities to tool, with predictable consequences.
We were using Visual Basic 6, which meant that UML could actually represent everything the language could do. I cannot think of any other OOP language that is limited enough to be described by UML.
I think that's the most ringing endorsement of VB6 I've ever heard. "Can be completely described by UML." They should've put that as a bullet point on the box.
1
9
5
u/Soza Jan 19 '11
I was put on a project at a prior employer that was using executable UML to generate drivers for their embedded product. The underlying code generation was pretty cool. The head guy on the compiler had a bunch of demos where he compiled UML down to a Lego Mindstorms unit. Actually using it on a daily basis, however, was the worst 3 months of my coding career.
2
u/abstratt Jan 19 '11
Ok, you got us intrigued. Why?
3
Jan 19 '11
If I had to guess, it is because cool != useful.
I've seen too many people waste years writing a DSL + code generator to make website programming easier. They always fail because in order to do what they truly want they have to keep making the DSL more and more powerful until it becomes a general purpose language.
A lucky few find that they just reinvented PHP or SharePoint. The rest get fired when the project is cancelled.
2
u/PstScrpt Jan 20 '11
Only if you try to use the DSL as the only language. Rails (parts of it, anyway), classic ASP and JSP are all essentially web development DSLs that seem to work decently. They all have a predictable relationship with a general purpose programming language, though.
1
Jan 20 '11
They also have the same escape valve: you can always just write pure HTML when you need to.
The people who I've seen get lost in code generator land think they can do literally everything with their DSL. Often they use terms like "configure", as if you can build an entire web site just by tweaking a database table or XML file.
I kid you not. I've seen more than one team create designs in which they evision that someone in marketing will create a sophisticated website just by tweaking knobs.
2
u/Soza Jan 20 '11
This is pretty close. The language wasn't expressive enough, but the company making the UML product wouldn't add the needed features. They were also dead set on their ideas and wouldn't listen to the poor saps who actually had to use it.
The UI was also aweful. No keyboard shortcuts, tons for repeditive actions.
2
u/quanticle Jan 19 '11
Your experience sounds like a way cooler version of mine. At least you got to see the cool demos. I just had to deal with the mess the code generators left behind.
5
u/freshtonic Jan 19 '11
For the love of all that is holy, WHY?!
A colleague of mine from 8 years back said that this Model Driven Architecture was the future and stated that within 5 years everyone would be programming this way. I wasn't exactly surprised when the 5 years came and went and developers were doing just fine without it.
I'm sure that some large, Dilbert-esque enterprises will lap this up eventually, and it will make them haemorrhage cash like all of their other failed enterprisey experiments.
But seriously, who the fuck wants this tech? Does any decent programmer ever find himself saying "fuck, if only I could draw this program as a diagram it would make my day"?!!
There is no way that programming at the diagraming level, and filling in the blanks with a neutered 'Alf' programming language is going to have and kind of mass appeal to good developers. To good developers, their existing languages are more than good enough for working at the level of abstraction they are designed for; they don't need to work in the neutered and inexpressive world of the Platform Independent Model (PIM) before finally passing it through the Platform Specific Model (PSM) to generate an app that can finally be run.
If your company starts heading down this path, tell them to go fuck themselves and get the hell out of there.
2
Jan 19 '11
The thing is we already have it.
I can open up Visual Studio right now and start drawing my class diagrams. When I'm done I'm left with matching code files in C# or VB just waiting for me to fill in the details.
Or I can use Visual Studio + Windows Workflow and not write any of the logic in traditional code.
The problem with the OMG is that they aren't programmers. If they were they would understand that the diagram tools only work when they are subservient to the language and framework being used. Instead they think the diagram is god and the languages need to conform to it.
This is why there are no languages, other than VB 6, that can be accurately represented by UML.
2
u/smallfishbigpond Jan 19 '11
Well, IMO, the thing is there shouldn't even be languages involved in this. The diagram is king. Why generate code at all, it's just a stupid artifact. Just compile the diagrams directly to executable code. Or to "managed" code if that makes you happy. You know the Lisp paradigm, code<==>data? Same idea. The model should be directly executable, and if it is not, then there is something wrong with your modeling language. The fact that the UML dweebs (and all the other modeling dweebs for that matter) haven't got this working by now tells me there is something wrong with their modeling language(s).
And to answer the question of who sits around wishing they could just draw a damn picture, I do. I know that in the current state of affairs this simply does not work. It's a joke, you know? It's just a way for some dudes to wear a shirt and a tie and have a job selling more crap tools to managers who don't know any better. I don't even try with this junk. I'm talking about how it could be, in a perfect world. Text files and convoluted make systems are stone age tools at best.
I WANT TO BELIEVE.
2
Jan 20 '11
A typical if statement with three clauses can easily take a third of a page. Imagine having to scroll through ten pages of diagrams for a twenty line function.
1
u/abstratt Jan 19 '11
You are mixing models with diagrams. I totally believe in executable models. Graphical vs. textual notation.is a completely different question.
1
u/abstratt Jan 19 '11
Now completely remove any traces of the idea of "diagrams" and reconsider the approach. Would you still have the same opinion?
3
13
u/[deleted] Jan 19 '11
Oh great, more worthless crap piled on top of UML.
In the mean time we still don't have a standard file format for UML diagrams, continuing to make this a joke of a standard.