The Great Refactor: Step 4: Make Heavy Use of Forward Declarations
Date: Wednesday, June 30 @ 03:35:35 CDT
Topic: The Great Refactor


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: 10:20 CDT on 30 June 2004.
FileUnneeded headersTime Processed abc





This article comes from xMule: A P2P Client derived from eMule
http://www.xmule.ws/phpnuke

The URL for this story is:
http://www.xmule.ws/phpnuke/modules.php?name=News&file=article&sid=22