How to design a program in C?

I

istillshine

Particularly for medium-sized (10,000 ~ 20,000 lines) programs, what
are useful strategies to design them before coding?

My strategies are:


1. Imagine what the final program would look like. Write down
options.

2. Write down many structures, such as

struct s1 {
/* contents */
};

struct s2 {
/* contents */
};

, and so on.

3. Write down many function prototypes, and classify them to different
..h files.


4. Write many macro definitions, such as "#define MAX_SIZE 100"

But having to change the original design during coding really troubles
me. Do you have any suggestions to avoid doing this?
 
B

Bartc

Particularly for medium-sized (10,000 ~ 20,000 lines) programs, what
are useful strategies to design them before coding?

My strategies are:
1. Imagine what the final program would look like. Write down
options.

2. Write down many structures, such as

struct s1 {
/* contents */
};
....
3. Write down many function prototypes, and classify them to different
.h files.


4. Write many macro definitions, such as "#define MAX_SIZE 100"

But having to change the original design during coding really troubles
me. Do you have any suggestions to avoid doing this?

This is all stuff you learn as you attempt bigger projects.

Revising/refining projects is quite normal (they get easier 3rd or 4th time
round..).

In my case, as I'm not quite au fait with C, I might write in a more
familiar and less fussy language (especially rapid development) then port
the result to C. Then you don't have to dot the i's and cross the t's on
code which might change a dozen times more.

Other people will suggest some very formal methodologies, but I think an
informal approach can still lead to reasonable quality code.
 
B

Bartc

Richard Heathfield said:
(e-mail address removed) said:


Er, those are iddy-biddy little programs.

LOC Range Category
0 Vapourware
1-9 IOCCC
10-99 Exercise/Example
100-999 Library update
1000-9999 Utility
10000-99999 Small program
100000-999999 Medium-sized program
1000000-9999999 Large program
10000000+ Very large program

The figures are more reasonable with Small programs starting at 1000-9999.
There are plenty of useful programs that can be written in 10K lines that
are more than utilities.

The 10M+ figure is better called 'bloatware'.

LOC is a fairly nebulous figure (as discussed in c.l.c last week I think).
But is useful for visualisation (every 15,000 lines is a 1" tall printout,
or divide by 200,000 to get that in feet; 10M lines is a ludicrous 50'
stack).

A lot depends on language and style. And, perhaps, how many of those LOC are
original and not just created by the developement environment.

And I think individuals should have their own scale; they can often create
similar applications to a team effort, with (necessarily) a smaller line
count.

So 10-20K LOC is plenty to qualify as medium-sized for an
individual.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,217
Latest member
IRMNikole

Latest Threads

Top