Академический Документы
Профессиональный Документы
Культура Документы
Acknowledgements
Thanks to all the highly skilled and experienced software engineers
who have shared their tips and best practice over the years. Many
of the tips in this booklet are drawn from their collective wisdom.
Contents
How to use this booklet ..................................................1
The fundamentals ............................................................3
Prefixes ..........................................................................3
Suffixes ..........................................................................5
Underscores ..................................................................6
Capitalization ................................................................6
Header File Guidelines......................................................7
Class and Function Design ..............................................8
Exported Functions ........................................................10
Code Style ......................................................................11
Construction ....................................................................14
Destruction ......................................................................14
Exception Handling and Memory Management ..............16
Defensive Programming ..................................................17
Additional Rules ..............................................................18
Further Reading ..............................................................19
References ......................................................................20
Developer Resources ......................................................21
1
The fundamentals
1. Compile with no warnings. Set your compiler to use
the highest warning level and compile your code
cleanly so it emits no warnings. If you do get
warnings, make sure you understand why and then
alter your code to remove them, even if the code
appears to run correctly despite generating a
warning.
Prefixes
TInt iCount;
CBackground* iBitmap;
TInt localVariable;
CMyClass* ptr = NULL;
class CActive;
class TParse;
class RFs;
class MCallback;
5
Suffixes
void AllocL();
6
Underscores
Capitalization
class TColor;
7
#ifndef GAME_ENGINE_H__
#define GAME_ENGINE_H__
#endif // GAME_ENGINE_H__
Exported Functions
16. Every function whose header file declaration is
tagged with IMPORT_C must have its implementation
tagged with EXPORT_C.
(i) they are not designed for use outside the library
Code Style
21. For efficiency, when initializing member variables in a
constructor, the use of member initialization lists
should be preferred over assignment statements.
Construction
39. The code inside a C++ constructor should not leave.
Destruction
42. When de-referencing a pointer in a destructor, the
validity of the pointer should first be checked in case
it has not been initialized or it has already been
destroyed by another destructor in the inheritance
hierarchy.
Defensive Programming
55. The checking methods of CleanupStack::Pop()
and CleanupStack::PopAndDestroy() should be
used where possible, to check that PushL() and
Pop() calls are balanced.
Additional Rules
59.
60.
61.
62.
63.
64.
65.
19
Further reading
For more information about writing C++ on Symbian OS
we recommend the developer titles published by Symbian
Press. More information is available at
developer.symbian.com/books.
References
Symbian Developer Network newsletter
developer.symbian.com/register
Symbian Press
developer.symbian.com/books
21
Developer Resources
Symbian Developer Network
developer.symbian.com
Forum Nokia
forum.nokia.com
Symbian OS Communications
Programming, Second Edition
Targeting Symbian OS v9.1 and v9.2,
Symbian OS Communications
Programming - Second Edition will
introduce you to the major
communications functionality in
Symbian OS and demonstrates how
to perform common tasks in each
area.
S60 Programming
Fully up to date for Symbian OS v9
and S60 3rd Edition, S60
Programming is an essential
foundation to developing software for
Symbian OS.
This practical book is based on the
authors’ experiences in developing
and teaching an academic course on
Symbian software development.
Published Booklets
Coding Tips
Performance Tips
Getting Started
Java ME on Symbian OS
P.I.P.S
Carbide.c ++
Data Sharing Tips
Essential S60 - Developers' Guide
Essential UIQ - Getting Started
Ready for ROM
developer.symbian.com/books