tags:

views:

254

answers:

7

I can clearly see the benefits of having UML diagrams showing your infrastructure of the application (class names, their members, how they communicate with each other etc).

I'm starting a new project right now and have already structured the database (with visual paradigm). I want to use some design patterns to guide me how to code the classes.

I wonder, should I code the classes first before I create UML diagram of it (maybe out of the code... seems possible) or should I first create UML diagram and then code (or generate code from the UML, seems possible that too).

What are you experiences telling you is the best way?

+3  A: 

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.

Finglas
+2  A: 

It is always good practice to have a design before you start. Whether that design is defined as UML diagrams or somewhere else does not matter. The question is what level of detail do you need ?

If in the environment you work in you need a design review before you start then you will need UML diagrams. They only need to be complete enough to convey what it is you are going to do.

Every place I have worked recently requires UML diagrams as a deliverable. What I do is create some basic ones up front and then modify them at the end, usually through reverse engineering the code.

Romain Hippeau
what software are you using to reverse engineer you UML into code?
never_had_a_name
@ajsie - Enterprise Architect
Romain Hippeau
+1  A: 
what are you experiences telling you is the best way?

I'm modelling in UML and if it comes to Interfaces and classes and sequence diagramms it is more comfortable to use IDE and declare them and do a round-trip engineering and see all these methods and attributes appear in UML diagramms.

It's too tedious to declare everything in an UML tool.

Just my opinion.

stacker
+4  A: 

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.

Jørgen Fogh
+3  A: 

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.

derdo
+1  A: 

I do model ( when I do ) before coding, with pencil and paper, but I don't do 3 weeks of diagram or anything like that. Just, 1 day or every iteration start.

Spending time in a diagramming tool is among the most ridiculous way to lose valuable coding time ( IMHO ) .

Using pencil / paper and cellphone camera has proven useful in the past.

OscarRyz
A: 

The best is to let users do as they want. I mean if they want to model first the database and then model the application, you need to transform your database into code and then reverse your code into UML. If you want to model first and then generate code and database then you need to create diagrams and then use code generators. If you want to model and code at the same time with love code and model synchronization then you can use Hibernate tools to map your design to the database once the conception has been finished.

The usual UML cycle is to model and then generate code using MDD technologies. I prefer iterative approach but except Omondo UML the other tools prefer to use MDD and not short UML iteration cycles. I don't know why but ....