Why isn't there more code generation from UML diagrams?
Asked by
ferry.landing
Is it possible to generate code directly from UML diagrams similar to how Simulink works in MATLAB? I've heard about some tools that can do this, but I'm curious why they haven't been widely adopted. Is it a matter of technical feasibility, or is there something about the industry's perspective that makes it unappealing?
Answers
The problem with UML is that it can be too ambiguous. Granted, there are tools that can generate basic code from structured definitions, but if the UML is too vague, you'll just get generic templates. For instance, there are tools like protobuf that handle higher-level structures well.
Reply to this answer
Yeah, some tools do exist, like those from Sparx Systems. They offer UML tools that claim to generate code, but they feel kind of outdated and are limited to Windows. A trial is available, but the tech feels a bit stuck in the past.
Reply to this answer
UML primarily tells you what the system should do, not how to implement it. To convert UML to code effectively, you need a detailed and well-structured approach. If the creators of the UML don't follow that structure, you're left with unorganized diagrams that don't translate well into working code. In the end, you might as well write out the classes and methods manually because it could save time in the long run.
Reply to this answer
There are JetBrains plugins that can convert UML to code, but honestly, the time you save is minimalโabout 3 minutes of work at best. It often feels like a hassle to set up for such little gain.
Reply to this answer
Actually, generating code from diagrams like Mermaid is more straightforward due to their clear schemas. From those diagrams, you can create full apps, including CRUD operations and REST APIs. The trick is having a way to customize the basic setup to fit specific needs, making it easier to adapt over time!
Reply to this answer
Technically, you can generate code from UML diagrams, but the output tends to be pretty basicโmostly boilerplate code. The diagrams usually lack enough detail to create comprehensive classes and methods. You'll end up with a lot of empty structures that still need a lot of manual editing to make them functional. So, while it's possible, it often just isn't practical.
Reply to this answer
I've worked on a project where we generated code from Sequence Diagrams as part of a simulation tool. It allowed us to create specific components for testing without running the whole simulation. The code was definitely boilerplate, but the experience of coding the tool itself was quite fascinating! It showed that while useful, it can be very simplistic.
Reply to this answer
Add your answer
Answers are reviewed before publication.
YepIndeed: That's a great point! With dynamic mappings, you could create a prototype application quickly and refine it continuously until it meets your needs. Itโs all about iterative development.
Moss_62: This is really interesting. I could see how one could generate a complete blog application from such diagrams! That would be a massive time-saver.