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?
7 Answers
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.
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.
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!
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.
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.
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.
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.
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.

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.