473,769 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1478

<is*********@gm ail.comwrote in message
news:45******** *************** ***********@u36 g2000prf.google groups.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*********@gma il.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.in validwrote in message
news:Q9******** *************** *******@bt.com. ..
is*********@gma il.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
1427
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. Very simple, the control works fine when creating it dynamicly from code. My aim is to add design functionality, so I can use it from the Visual Studio .Net toolbox. When I compile my code, no errors are reproted and Visual studio leaves a
13
2105
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 example is a program called HijackThis. I'm sure many are familiar that it is a spyware removal tool. The program looks at over 20 places on Windows computers to see what is starting (with options to remove the offending software). The program can...
11
2363
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 similar to a database or XML representation. Rules to modify the stored data will be executed, then the data will be transformed into an output format. Think something similar to FormatA -> XML -> Manipulate XML -> FormatB
23
2387
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 follow for creating a program? I am writing a map game program. I created several objects: board object that is an array of integers each number 0-5 is a kind of terrain, a terrain object that is an array of terrain types and each number of...
10
2349
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. #include<iostream>
0
2509
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 don't work nearly as well as they should, even for analysts and power users. The reason they haven't reached the masses is because most of the tools are so difficult to use and reveal so little
6
2140
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 times when I program, I will create objects for a specific purpose for a program and if I need to add to it I just add the code.
9
2824
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 the including "colors markup" is useless of the marks, the marks is unneccessary extra information. The most used way to make colored view of C++ programs is usage of classes of C++ language words (already included in C++): reserved words, user...
12
8031
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 coding and just let the program evolve the features required. My concern is no so much the method, everyone uses this design method at sometime (I recon) even if it is just for a test bed investigating the method to perform some operation. ...
0
10211
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9863
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8870
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7408
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3958
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.