 |
Who's Online |
 |
|
There are currently, 2 guest(s) and 0 member(s) that are online.
You are Anonymous user. You can register for free by clicking here
|
|
|
 |
| |
Coding Blog: The Great Refactor: Step 4: Make Heavy Use of Forward Declarations
Posted by HopeSeekr on Friday, August 20 @ 15:52:48 CDT
Contributed by HopeSeekr
Now that we have sufficiently plotted the dependencies of objects via header documentation (1, 2) we can now get to the Good Stuff (TM): Heavy use of Foward Declarations...
Briefly Forward Declarations are used by elite hackers instead of #includes wherever possible, especially in header files.
Forward Declarations
• Require only 4 bytes of storage (or the size of a memory address) irregardless of the real size of the object (decreased memory).
• Do not need to 'know' the details of their declarations (decreased compile time).
• Are independent of their definitions (decreased possibility for errors + extensibility).
• Useful for circular dependencies (where foo requires bar requires foo).
• Greatly-increased encapsulation (greater over-all program security).
• Far less explicit code in the application (increased code optimization).
The simple fact is, headers are not always needed. You should use Forward Declarations instead of headers if the following are true
• The object is stored as a pointer.
• The module does not require run-time specific details of the object (its functions, internal variables, etc).
Since they can only work when you do not need to know the details of the object's declaration, Forward Declarations are most often used in header files. Because of my recent work revolved around plotting the modular interdependencies (via documenting headers), I can now fairly easily create Forward Declarations wherever possible. Doing so to the extreme, and then restructuring xMule itself to allow for ever-greater numbers of Forward Declarations stands to increase the efficiency of xMule in the numerous domains already cited.
If you want to help in this endeavor, be sure to get in touch with me either via email or IRC.
Cheers,
-hope
Start time: 14:48 CDT on 20 August 2004.
FileUnneeded headersTime Processed
AddFriend.h1 out of 114:48
|
|
| |
 |
Login |
 |
|
|
Don't have an account yet? You can create one. As a registered user you have some advantages like theme manager, comments configuration and post comments with your name.
|
|
|
 |
 |
Article Rating |
 |
|
Average Score: 3 Votes: 2

|
|
|
 |
|
| "The Great Refactor: Step 4: Make Heavy Use of Forward Declarations" | Login/Create an Account | 1 comment | Search Discussion |
|
| | The comments are owned by the poster. We aren't responsible for their content. |
|
|
|
No Comments Allowed for Anonymous, please register |
|
|