473,808 Members | 2,852 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need recommendations for code modularization

ern
I inherited a huge C application and most of it is in one file. I'd
like to modularize it into several different files. Is there a good
resource for learning the best way to link C files together... and
maybe some good conventions to use?

Thanks,

Jan 12 '06 #1
36 1837

ern wrote:
I inherited a huge C application and most of it is in one file. I'd
like to modularize it into several different files. Is there a good
resource for learning the best way to link C files together... and
maybe some good conventions to use?


Places to start:

1) global variables: divide the functions by the variables they access.
2) structure definitions: divide the functions by the structures they
use.

Hope this helps. karl m

Jan 12 '06 #2
Ian
ern wrote:
I inherited a huge C application and most of it is in one file. I'd
like to modularize it into several different files. Is there a good
resource for learning the best way to link C files together... and
maybe some good conventions to use?

Your compiler manuals?

Look for logical groupings of functions and variables and keep them
together in the new files.

The biggest problem you will find will be converting between static
variables (or functions) in the one file to global/shared across many
files. You will either have to make things global, or create some form
of encapsulation, depending or you style preference. In my experience,
the pain will lead to a better design, but you had better have a good
set of tests before you start the process.

Ian
Jan 12 '06 #3
I am currently going through the same thing. I have been trying to
make accessors and mutator functions that act on the global variables.
Also, I have been using a program called Understand for C++ by
Scientific Toolworks Inc (www.scitools.com). It generates a lot of
information about your code. For example if you click on a variable it
tells you were it is defined, used and modified. It tells you what
functions call other functions. It has saved me a great deal of time,
although the cost was a little step.

Jan 13 '06 #4
matt wrote:

I am currently going through the same thing. I have been trying
Same thing as what? Without context you make no sense. See my sig
below. Please be sure to read the URL before posting again.
to make accessors and mutator functions that act on the global
variables. Also, I have been using a program called Understand
There are no such things in C.
for C++ by Scientific Toolworks Inc (www.scitools.com). It
C++ is another language, found down the hall to the right.
generates a lot of information about your code. For example if
you click on a variable it tells you were it is defined, used
and modified. It tells you what functions call other functions.
It has saved me a great deal of time, although the cost was a
little step.


It is remotely possible that with context your comments could have
been topical. Without it, they are just off topic nonsense here.

--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell. org/google/>
Jan 13 '06 #5
"Chuck F. " <cb********@yah oo.com> writes:
matt wrote:
I am currently going through the same thing. I have been trying
Same thing as what? Without context you make no sense. See my sig
below. Please be sure to read the URL before posting again.


[snip]
--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell. org/google/>


I suggest updating the boilerplate slightly. It's been brought to my
attention that there's another workaround for Google's interface
problems, one that might be more convenient for some users. Rather
than going through the "show options" link, you can:

Click the "Reply" link at the bottom of the article.
Click the "Preview" button.
Click the "Edit Message" button.

Chris F.A. Johnson has updated his web page to reflect this.

Since Google users are going to be viewing this from their web
browsers anyway, it's probably sufficient just to point to Chris's web
page rather than repeating the instructions.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Jan 14 '06 #6
Keith Thompson wrote:

[snip]

I suggest updating the boilerplate slightly. It's been brought to my
attention that there's another workaround for Google's interface
problems, one that might be more convenient for some users. Rather
than going through the "show options" link, you can:

Click the "Reply" link at the bottom of the article.
Click the "Preview" button.
Click the "Edit Message" button.

Chris F.A. Johnson has updated his web page to reflect this.

Since Google users are going to be viewing this from their web
browsers anyway, it's probably sufficient just to point to Chris's web
page rather than repeating the instructions.


I'm not sure I agree. I suspect the googler doesn't want to break
off whatever thread he is reading to check another webpage,
although they probably can without harm on most browsers. Thus I
think having a suitable mechanism right under their noses will help.

I gather that the new method is simply another alternative, and
requires conscious effort, rather than being the default. This is
stupid, because nobody wants to wait for more intermediate pages to
arrive.
--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
More details at: <http://cfaj.freeshell. org/google/>
Jan 14 '06 #7
Chuck F. wrote
(in article <gd************ *************** ***@maineline.n et>):
Keith Thompson wrote:

[snip]

I suggest updating the boilerplate slightly. It's been brought to my
attention that there's another workaround for Google's interface
problems, one that might be more convenient for some users. Rather
than going through the "show options" link, you can:

Click the "Reply" link at the bottom of the article.
Click the "Preview" button.
Click the "Edit Message" button.

Chris F.A. Johnson has updated his web page to reflect this.

Since Google users are going to be viewing this from their web
browsers anyway, it's probably sufficient just to point to Chris's web
page rather than repeating the instructions.


I'm not sure I agree. I suspect the googler doesn't want to break
off whatever thread he is reading to check another webpage,
although they probably can without harm on most browsers. Thus I
think having a suitable mechanism right under their noses will help.


BTW, I seem to remember that Google snips sigs ENTIRELY when
displayed in their web interface. As such, when you post text
in your sig on how to work around google interface issues, they
may never see it at all.
--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw
How 'bout them Horns?

Jan 14 '06 #8

Randy Howard wrote:
Chuck F. wrote
(in article <gd************ *************** ***@maineline.n et>):
Keith Thompson wrote:

[snip]

I suggest updating the boilerplate slightly. It's been brought to my
attention that there's another workaround for Google's interface
problems, one that might be more convenient for some users. Rather
than going through the "show options" link, you can:

Click the "Reply" link at the bottom of the article.
Click the "Preview" button.
Click the "Edit Message" button.

Chris F.A. Johnson has updated his web page to reflect this.

Since Google users are going to be viewing this from their web
browsers anyway, it's probably sufficient just to point to Chris's web
page rather than repeating the instructions.
I'm not sure I agree. I suspect the googler doesn't want to break
off whatever thread he is reading to check another webpage,
although they probably can without harm on most browsers. Thus I
think having a suitable mechanism right under their noses will help.


BTW, I seem to remember that Google snips sigs ENTIRELY when
displayed in their web interface.


No, it doesn't.
As such, when you post text
in your sig on how to work around google interface issues, they
may never see it at all.
In fact, I get yelled at because not only are they displayed,
but they are included in the quoting.


--
Randy Howard (2reply remove FOOBAR)
"The power of accurate observation is called cynicism by those
who have not got it." - George Bernard Shaw
How 'bout them Horns?


Jan 14 '06 #9
Chuck F. said:
Thus I
think having a suitable mechanism right under their noses will help.


(Subject line: "Housebreak ing googlers")

Did you mean "Housetraining" ? In the UK at least, "housebreak ing" has a
completely different meaning.

I can't help thinking of a guy in a black beret, a mask over the eyes, a
hooped yellow-and-black jersey, a coarse sack with "SWAG" written on it in
large black letters, a jemmy or crowbar, and a laptop. Presumably he only
has dial-up at home, is disgusted with his phone bill, and would therefore
rather use someone else's landline for his surfing.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at above domain (but drop the www, obviously)
Jan 14 '06 #10

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

Similar topics

0
3100
by: Linus Nikander | last post by:
Browsing peoples comments at amazon might be rewarding, but it sure takes a lot of time. I'm trying to find good (best) books for a couple of java-related areas. As most people who subscribe to this newsgroup probably have a bunch of books at home this should be the ideal place to ask for recommendations. So, what are your recommendations for good books on any/all of the following subjects: J2EE Patterns Struts JUnit (or testing in...
0
1660
by: Peter Rohleder | last post by:
Hi, I have a few simple questions in order to use modularized xhtml and getting it to work. A simple example may make this obviouse: Lets say we want to create a simple xml-file to reflect a faq-structure.
6
3161
by: Peter E. Granger | last post by:
First, I would like to apologize in advance if this is not the appropriate place to post this message; of the .NET-related newsgroups I found, this seemed to be the most general. If the information I'm requesting is covered in a FAQ somewhere, please point me to it, and I'll be happy to read it. A group of friends and I, mostly professional developers, have decided that it is time for us to learn .NET. We are (variously) versed in C, C++,...
0
1574
by: VP | last post by:
G'day folks, well i am attempting to get an understanding on how to create the menuitems in a context menu on the fly. So far I have managed to actually achieve the menu items being created for the context menu. However, I have stumbled across one problem. Which is that how does one go about enhancing the event handler for the context menu to invoke individual actions for each of the menu items. I have included a snippet of my code....
44
2600
by: shuisheng | last post by:
Dear All, Assume there are three classes where CA has members of class CA1 and CA2 as follows. To make the public functions of CA1 and CA2 can work on the members a1 and a2 in a CA object, I just write all the functions such as a1_func1(), a1_fun2(), a2_func1(), as_func2() in the CA interface. I think this is a stupid way since if there are more functions in CA1 and CA2, I need to repeat them all. Is there any good way to implement it?
1
1555
by: Billy Biro | last post by:
Hi. I'm looking for some recommendations for Visual Basic 2005 books. Specifically, I'm NOT looking for books that detail the elements of the language, nor explain OOP, but rather present real-world scenarios for application development, and show how classes/components can be developed together to form the overall application. As an example, I already have a copy of Wrox's "ASP.NET 2.0 Website
0
2197
by: C.W.Holeman II | last post by:
As K&R state the hardest part is getting a first instance to work. So I am looking for a "hello, world!" example for adding an additional element to an XHTML file. <html> <head><title>Hello, World</title> <body> <h1>Hello, World</h1> <myHello> <p>My hello.</p>
1
1409
by: Maryanne | last post by:
1) How do I display in a form a string of 1:M relationships? (or does it need to resort to multiple forms?) * Starts with Client that has consultant and consultation desk. Client has many questions. Question has many recommendations which has many followup replies. *What I have done so far: I placed client in header of form. Then questions is in a subform. *Problem: Subform shows many questions but now for each question I need to...
0
3368
by: mk189 | last post by:
Hi, I am trying to create XML schema of custom markup language, enriched by XHTML. In simplified version, the XML documet could look like that: <a:alarm-manual xmlns:a="alarm-manual" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="alarm-manual alarm-manual.xsd" <h:p>Text ... <a:par-value name="myName"/... text </h:p>
0
9600
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10374
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9195
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
7651
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
6880
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
5547
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5685
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4331
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
3859
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.