Application Design
An application that is poorly designed will gain more out of re-design than performing small tweaks and improvements. Optimization should not be the last step, but should be built into the design when choices such as the algorithms and data structures are decided. Note that actually optimizing chunks of code *should* be last and done by profiling. An excellent book that covers this topic in depth is Code Complete: A Practical Handbook of Software Construction by Steve C McConnell.
Utilizing Existing Classes
Often times developers will write their own classes when in fact, one already existed that they simply did not know about. You should be familiar with the toolkits and the classes in them. Take some time exploring the toolkits documentation to fully find out what it has. You don't need to know all of the details of every class. Simply know what exists so when you need something you wont re-implement it yourself by accident. Classes that are included in the toolkits are generally optimized and bug free because many developers have looked at them.
KDE Documentation: http://developer.kde.org/documentation/
QT Documentation: http://doc.trolltech.com/
Optimizing C++ Code
Just like software design, C++ optimization is far beyond the scope of this article. Here are a few books that have been specificlly written about how to optimize C++ code.
C++ Footprint and Performance Optimization by Rene Alexander and Graham Bensley
Efficient C++: Performance Programming Techniques by Dov Bulka and David Mayhew
More Effective C++: 35 New Ways to Improve Your Programs and Designs by Scott Meyers
The Association of C & C++ users has a comprehensive listing of computer science books along with reviews.
Doing a search on Google will also bring up some sites that have been created about optimizing C++. Here are a few of them: 1, 2, 3, 4, 7, 8. Although some good information can be attained from these sites, getting a comprehensive book is still recommended, as it will cover a magnitude more. If you have a book or site that you would like to recommend, drop me a line and I will add it. Last but not least check out KCachegrind, which can be used to profile an application and find problem areas that should be improved.
Conclusion
Remember that in almost all cases where GUI applications are involved, you shouldn't go overboard in trying to improve functions. Doing so can complicate the functions to the point where they become difficult to maintain. Application designs should be clean rather than fast.

0 comments:
Post a Comment