Long-time readers know that a few years ago the portal included a set of online code-generation services
- UMLtoSQL: automatically generated a SQL DDL script to create the database corresponding to the input UML class diagram
- UMLtoPHP: automatically generated full-fledged PHP applications from UML class diagrams. The service generated Doctrine models that thanks to the PHP/Symfony framework were sufficient to generate a full web application offering all typical CRUD operations.
- UMLtoPython: full-fledged Python/Django applications from UML class diagrams. The service generated the models.py and admin.py files required by Django in order to automatically generate all the CRUD functionality for the application.
They were a completely failure from a business point of view (for several reasons as I reflected at that time) but since some people seems to be interested in the project itself I’ve released it as open source software.
Feel free to clone / contribute to the Git repository I’ve created in GitHub . I still believe in the ideas behind those services, mainly the idea of having smart code generators implementing the Pareto Principle for model-driven development20% of the modeling effort suffices to generate 80% of the application code Click To Tweet
where many of the “dumb” CRUD code can be easily automatically generated (without having to explicit model that functionality) through scaffolding features offered by the target programming framework.
And I do have plenty of ideas of how to move this forward (e.g. there are now some pretty interesting full-stack Node frameworks like Keystone.js that could be a nice target) but I doubt I will have the time to work on them anytime soon so feel free to offer a helping hand!. Do it, even if you don’t think the current code can be reused in any way, again, exploring these ideas and discussing how to make them possible is the goal so I’m open to any kind of collaboration on this.
DISCLAIMER: This is just the core of the classes I was using at the time. Those classes were never created with the intention to release them to the public so there are not commented (and/or some comments may not even be in English), code is of low-quality and all the other possible disclaimers you can imagine. Any use of those classes is at your own risk (but I still hope they are useful to somebody).
ICREA Research Professor at Internet Interdisciplinary Institute (UOC). Leader of the SOM Research Lab focusing on the broad area of systems and software engineering. Home page.
I’ve been modelling sql queries with UML (subqueries also but not unions nor other extended queries), but don’t know if there is a mainstream way of doing this…
I just do an abstraction from the input parameters to the principal entity, and a complex abstraction from the output object to the principal entity, adding the needed associations of the entity as abstraction suppliers to be treated as joins. A new class is used to model subqueries. Every field defines in a Opaque expression the mapping between the supplier entity field and the output field .
The where, group by or order clauses are modeled as output object contraint’s opaque expression.
Why don’t you use OCL to model the queries ?
Simplify is a must, and UML allows me to modelize simple queries at a simple high level, using opaque expressions for target languages. Languajes like QVTr or OCL lack from SQL functions and are hard to parse analyze and transform. It’s difficult for me to describe a ‘group by X having Y’ in ocl. Actually the most useful languaje for querying relational models I know is JPQL, and transforming JPQL to OCL semms to be easier than OCL to JPQL.
Until OCL provides this functionalities, anyone can implement its functionality his own way, and reversing this code to group by sentences could be very complex.
In my opinion, any query or constraint should modelized as UML activities, and commented in other languajes to simplify its understanding. This should minimize entropy.
Thanks for being interested.
What you say about the OCL limitations is unfortunately true. We showed here: http://modeling-languages.com/aggregation-functions-ocl/ how to extend OCL to cover some of these missings operations