473,395 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to design a program in C?

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?
Jun 27 '08 #1
5 1458

<is*********@gmail.comwrote in message
news:45**********************************@u36g2000 prf.googlegroups.com...
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.

--
Bart
Jun 27 '08 #2
On Sun, 13 Apr 2008 16:07:21 -0700, istillshine wrote:
But having to change the original design during coding really troubles
me.
It shouldn't.
Do you have any suggestions to avoid doing this?
Don't avoid it. Embrace it. Changes to designs happen, and not just in
software.
Jun 27 '08 #3
is*********@gmail.com said:
Particularly for medium-sized (10,000 ~ 20,000 lines) programs,
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

(Source: BSI, 2008 [1])
what
are useful strategies to design them before coding?
Identify the requirements. If you know how to implement these requirements,
write down how to do that. Otherwise, break the requirements down into
simpler sub-problems, and recurse. Look for commonalities between various
parts of the problem, and use those to factor out functionality. Look for
aspects of the problem that are general computer problems rather than
aspects of this particular problem, and see whether you have existing
library solutions for those parts. If not, consider creating them this
time round, to make life easier next time round.

My strategies are:

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

2. Write down many structures, [...] many function prototypes, [...]
many macro definitions [...]
I hope I'm wrong, but this almost sounds like you're inventing these things
at random! I would suggest that you think in terms of modules. "I will
need a module for dealing with customers, a module for dealing with
suppliers, a module for managing transactions..." and so on.
But having to change the original design during coding really troubles
me. Do you have any suggestions to avoid doing this?
Even if you get the design right (which you probably won't because hardly
anyone does, and this is normally *not* their fault because normally they
haven't been told correctly which problem they're supposed to be solving),
by the time it's finished the requirements will have changed, which
necessarily means a change in design. Welcome to the ever-changing world.

That's why the "Cathedral" design process doesn't work very well - it can't
respond quickly to changing requirements. Write well-modularised code,
usefully solve *one* problem, and release the code, asking for review
comments and telling your users when, roughly, to expect the next release
(tomorrow? day after? next week?) and what problem it intends to solve,
and so on round all the problems. That way, your users become involved
iteratively in your design process, and you can satisfy their needs much
more quickly, effectively, and flexibly.
[1] Those who are wondering whether I mean the British Standards Institute
need wonder no longer. I don't.

--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999
Jun 27 '08 #4

"Richard Heathfield" <rj*@see.sig.invalidwrote in message
news:Q9******************************@bt.com...
is*********@gmail.com said:
>Particularly for medium-sized (10,000 ~ 20,000 lines) programs,

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.

--
Bart

Jun 27 '08 #5
>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'.
This, I suppose, depends on what it's supposed to do.
If it's the Windows Vista driver for the second mouse button, it's bloatware.
If it's a planetary air traffic control system, it might not be.
>LOC is a fairly nebulous figure (as discussed in c.l.c last week I think).
The ease with which a programmer can greatly magnify LOC (and maybe
billable $$$) using an automated program indicates it's much more
nebulous than that.
>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).
Yes, and by providing the outside of a 50' stack of paper with the inside
filled with manure, you can make something look complicated when it's not.
>A lot depends on language and style.
Applying LOC to a program alters the style to maximize LOC.
>And, perhaps, how many of those LOC are
original and not just created by the developement environment.
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Mobile Boy 36 | last post by:
I'm trying to make a very simple Textbox with a FocusColor property...When the focus changes to the control, the backcolor must change automaticly to the color set by the focusColor property....
13
by: KV | last post by:
I'm new to OO Design, and I'm fixing to start writing my very first C# program. Given the complexity of OO programming, I would like to run something by this group and get general input. My...
11
by: John Fly | last post by:
I'm working on a large project(from scratch). The program is essentially a data file processor, the overall view is this: A data file is read in, validated and stored in a memory structure...
23
by: JoeC | last post by:
I am a self taught programmer and I have figured out most syntax but desigining my programs is a challenge. I realize that there are many ways to design a program but what are some good rules to...
10
by: sunny | last post by:
Does this following program implement the factory design.if not what are things that i have to change in order to make this following program to be designed to factory design pattern. ...
0
by: YellowFin Announcements | last post by:
Introduction Usability and relevance have been identified as the major factors preventing mass adoption of Business Intelligence applications. What we have today are traditional BI tools that...
6
by: JoeC | last post by:
I have a question about designing objects and programming. What is the best way to design objects? Create objects debug them and later if you need some new features just use inhereitance. Often...
9
by: Grizlyk | last post by:
Somebody have offered std colors to C++ in the msg here: http://groups.google.com/group/comp.lang.c++/browse_frm/thread/2e5bb3d36ece543b/1acf6cd7e3ebdbcd#1acf6cd7e3ebdbcd The main objection to...
12
Banfa
by: Banfa | last post by:
I was mildly concerned when I saw else where on the forum on of our experts express the opinion that software design saw not required and their prefered design method of development was to just start...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.