BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Splitting units into several .cpp files

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++)
View previous topic :: View next topic  
Author Message
Michele Santucci
Guest





PostPosted: Tue Aug 02, 2005 10:10 am    Post subject: Splitting units into several .cpp files Reply with quote



Hello NG,

I wrote a form that counts about 6000 lines of code and this's pretty long
in compiling ...
There's a "clean" way to split it into several sub-units?

--
Michele Santucci
===================
Celin Avio S.r.l.
Software Dev. Manager
--------------------------------------
tel. +390187564080
Via Fontevivo 21/M
19126 La Spezia
===================


Back to top
Andrue Cope [TeamB]
Guest





PostPosted: Tue Aug 02, 2005 10:32 am    Post subject: Re: Splitting units into several .cpp files Reply with quote



Michele Santucci wrote:

Quote:
Hello NG,

I wrote a form that counts about 6000 lines of code and this's pretty
long in compiling ... There's a "clean" way to split it into several
sub-units?

Not really. You could split it into separate files then use #include to
link them back together but that would actually slow things down.

Split the big unit into several separate, self contained units. Then
create a single overarching header that includes all the separate
headers. Try to create a separate header for declarations required by
all the new subunits.

The idea is to make each of the new units as self contained as
possible. That way you can change their headers without requiring
recompilation of the other units.

So, REFACTOR.CPP and REFACTOR.H becomes:

REFACTOR_COMMON.H // Declarations needed by all subunits.

REFACTOR_A.CPP // includes REFACTOR_COMMON.H then REFACTOR_A.H

REFACROR_B.CPP // includes REFACTOR_COMMON.H then REFACTOR_B.H

REFACTOR.H is a new file that does nothing but include the common
header then all the subunit headers.

The idea here is that client code can just include REFACTOR.H and get
everything it needs that way. The individual units however are only
dependant on their own headers and the single common header.

You could have the subunits include REFACTOR.H but then any change to
any of the subunit headers will cause all the other units to be
recompiled.

--
Andrue Cope [TeamB]
[Bicester, Uk]
http://info.borland.com/newsgroups/guide.html

Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Language C++) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.