Designing classes

Lately I've been trying to do a lot more design before sitting down and cranking out code, thinking that it would cut down on some of the iterative revisioning I see being the staple of programming. But how to do that design without having to do it all over again once the coding starts.

UML is cool and all, but I find it better for explaining things to others, after the design has progressed, than for designing objects. It also doesn't let me express C# syntax properly and I still have to transcribe everything by hand into the IDE later on and the link between the two is lost.

I could write out the object design as text, describing inheritance, members, etc. That usually works best for me, but then I still have got to transcribe it into the IDE and again the link between design and implementation is lost.

I briefly played with code generation, creating an XML schema to define the classes, then generating code from that. Still suffers from the design/implementation disconnect. As soon as the generation is done, and i fill in the code, they diverge. I considered writing the Code Generator to be able to parse the code back in, update the XML and then be able to generate any changed code from that.

I think I've stumbled across a better approach though. Integrating straight into VS.NET and using the CodeModel that the IDE builds on the source files, to alter and design classes. Everything stays in the native code format, but i can still tweak it without touching code.

My current design goal is an Add-in that mimics the Object Browser, but allows you to alter the classes on the fly, as well as add new classes, members, etc. Then build onto it a way to create "code templates" so that you can autogenerate more than just method stubs, such as creating fields with accessors. Eventually you have a Class Editor with a plug-in system for code generation templates. If i then add a way to annotate the design, probably by extending the XML doc format already in there, i have a nice system for keeping design and implementation together.

So far, my add-in can mimic the Object pane of the Object Browser. Tonight I hope to add the Member pane functionality, then comes Adding new classes/members.