Getting Prepared/Planning
For the first time, I am trying to create a rather large .NET project. I think the largest one I have made so far was about 6 classes, but this one is already at 14. For the section I'm starting to work on, I'm having some trouble putting everything together in my head, which is what I normally do. I think it's just a little too complex for that. I want to plan it out, and I want some way to visualize it and be able to play with it and manipulate the开发者_JS百科 structure easily. Is there any sort of (free) program I can use to do this?
Do you have access to a whiteboard? Software tools are great, but I've always found drawing it out by hand really helps me think through design problems. Just start with some boxes which represent the problem at a high level, then begin fleshing it out from there.
That, and I hear the marker smell is scientifically proven to increase creativity.
Pen and paper is often good enough, because you don't really want to get to a state where you can't visualise your problem on a single sheet of paper. When designing solutions, try to break the problem down into them down into smaller sub problems. Applied to class design, this is called the Single Responsability Principle. Ideally, do it in a way so that the classes are independent, rather than coupled. If they have to be coupled, keep it as minimal a possible. You'll end up with more but smaller classes that are easier to maintain and you'll need to keep less of the whole program in your head at one time.
A good (free) tool to visualize the dependencies in your codebase is NDepend. It can be a bit overwhelming at first and needs a bit time invested to get the most out of it.
Visual Studio can make Class Diagrams. (In the Add new Item dialog)
You might also consider astah
Here's a GNU-licensed UML design tool: http://www.umlet.com/
UML Class Diagrams will help you figure out your object model. The others (Sequence, Use Case) will help you plan to meet your requirements.
Good ole' pencil and graph paper. Let's you line things up better, draw better boxes, draw straight lines and makes you feel like an engineer designing some high-tech piece of machinery, which in an abstract way you are.
I agree highly with the pencil and paper method. In addition to doing a class diagram, which is something that's fairly common but gives a static view of elements of your solution, I like to do sequence diagrams. These help clarify the relationships and responsibilities between the classes and, importantly, help you identify just the methods that you need to implement.
精彩评论