Create UML diagrams after or before coding?

I always create them during development. This is a personal bias though.

Following iterative development for example means your code will evolve as the project progresses. Creating UML diagrams up front is therefore a waste of time, as after a while your end result will be nothing like the diagrams you started out with. Even with iterative development, things such as Test-Driven Development do not discourage UML diagrams. During the planning/design process for a story/task, UML diagrams can come in quite handy. However, that's not to say you should blindly write UML for every piece of code you write.

In contrast, UML diagrams allow you to express large ideas to other developers in a few simple images. From the diagrams other developers can grasp how the application/components are linked.

You're best off using UML diagrams as a tool, rather than a means in my opinion. Having industry experience I can assure you that just because books tell you to write UML/carry out extensive design before writing any code, it very rarely, if at all, works like that.


The important thing is that you think, before, during and after you code. If UML helps you do this, you should use it. Depending on the program you are writing, you might want to focus on algorithms, architecture or the user interface before you write the code.

Even before you start thinking about how you should write the program, you should also think about what you should program. Again, the kind of program you're writing dictates what exactly you should think about.


I think for documentation purposes UML diagrams are close to worthless since keeping them up to date is almost impossible. However I think that they are good tools before and at the starting stages of development for thinking over design and also reviewing it with other team members. So my answer would be a little bit before a little bit at the starting stages and not so much after that.

Tags:

Oop

Uml