Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm fairly new to Visio, and was wondering if there's a way I could auto-generate the code from Visio diagrams.

I was looking to generate either C# classes, SQL statements for building the database layer, or EntityFramework objects. I am using MS Visio Professional 2010

share|improve this question

3 Answers 3

up vote 7 down vote accepted

Please don't.

Code the classes correctly.

Code the SQL correctly.

Expansion per Ali's request below:

If you are going to make the diagramming tool expressive enough to capture the full range of expressiveness of the the programming language, you have essentially recreated the programming language, but in a non-supported way (what happens when you move to C#5.0?). If you have some of the expressiveness but not all, then the tool will be limited in its ability to generate the code, and you'll have to add hand-coding to make it just right. This means you'll then not be able to make design changes in your diagram tool for fear of knocking out your hand-coded code.

Bonus point: How do you version control your diagrams?

share|improve this answer
    
Ok. I was wondering if they could be used to avoid duplicate work. After I asked this, I found another question which suggests the class diagrams are used for design only, then thrown out and replaced with auto-generated ones after implementation. programmers.stackexchange.com/questions/6677/… –  Rachel Feb 14 '11 at 16:46
    
Why? Please expand upon your answer. What is your experience? Why was it apparently bad? –  Ali Feb 15 '11 at 14:31

How are you going to maintain them after you do generate them? One-way code generation is almost invariably a big mistake. Why not write the code, and generate the diagrams? Writing code is a lot faster than drawing diagrams.

share|improve this answer

With the reverse engineer wizard in Microsoft Office Visio, you can create a database model from an existing database. Try reverse engineering the wizard of Visio Professional to create code from diagrams. I have never used this though, but looks like it should work. Check it out to see whether it works for you or not. There's currently a free 60-day trial promo going on too!

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.