 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Michele Santucci Guest
|
Posted: Tue Aug 02, 2005 10:10 am Post subject: Splitting units into several .cpp files |
|
|
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
|
Posted: Tue Aug 02, 2005 10:32 am Post subject: Re: Splitting units into several .cpp files |
|
|
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 |
|
 |
|
|
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
|
|