Hey, how do you guys design programs?

This is a general question, how do you design a problem?
What's your general steps?

There is no doubt that if you start coding with out sort things out first, it will lead to a disaster, more and more functions just jump out of nowhere, at last it's impossible to manage the code, I've gone crazy for so many times, the only way to finish it is re-write the whole program, which is very frustrating.

In my way now, I firstly write down the basic description of my goal, this is normaly very easy and simple, if I was trying to do a test problem then the goal is already given.

Secondly, I try to figure out like 3 or 4 steps to achieve the goal, these are functions. Then for each of the functions, I repeat this procedure to divide it into more precise ones, eventually the functions are close enough to C++ sentences(you can write it in less than 10 lines).
I draw a SN graph to represent the connections, so finally i'll get a function tree.

Finally, I'll start from the bottom. That is, from the smallest functions. After finished some functions, I may write a little unit test to see if i got everything right. Keep repeat this procedure until i finally got the whole program.

Sometimes this works fine, but actually there is a "little" problem here, that is how small do I have to divid funcions into? Too small is like writing the whole program on the paper, and too large is like doing notiong. Any suggestions?

And I'd really want to know how you guys do the program, what is your way?

At present i haven't code a "big" project, the biggest project i've written is like 1.5k lines, in 5 files. So for the big projects, how do you make the plan?

I start with requirements; a functional description of each action that needs to be supported by the application.

From the requirements I generate use-case diagrams, a set of diagrams which describes all of the actions that the user will take and how they interact with each actor (user or database).

Once I've gone through the use-case diagrams I usually have a pretty good idea regarding what classes I'll need. I start off with my executive classes and define the methods and members associated with each class. I also define the relationships between each class ( A contains B, A is B, A has B, A has a reference to B, etc.).

Keep going through the requirements and use-cases and tuning your class interfaces/relationships until all of your requirements are met.

Next you can eliminate, combine, generalize functions to ensure maximum re-use of code.

Once all of that is done, you're 90% done your program. Now you just have to code it.
Hi Stewbond,

First of all, thanks for your reply!

It seems that you are working on some fairly big projects, since you have many classes and got some users instead of just myselft. That's pretty much what I've wanted to hear. Thanks.

And the last two sentences you wrote:
Next you can eliminate, combine, generalize functions to ensure maximum re-use of code.

Once all of that is done, you're 90% done your program. Now you just have to code it.

sounds very very impressive to me, it's reads just like a saying by some famous guys on the beginning of each chapter on programming books! And it's the fact, indeed.

90% of programming is not made up by typing the keyboard.

OMG I should put it on my wallpaper!!! You're great!
Topic archived. No new replies allowed.