3
Ten C++ coding tips
This micro guide is the first of a colection dedicated to c++ dvelopers that want to prodcuce a more robust code.
These suggestions are only a quick guide based on our experience as mobile developers.
1) Ensure that your application responds to system shutdown events.
2) Ensure that your application responds to incoming system events. Remember that your application is operating on a multitasking enviromnment and for this reason you need to pay attention to focus gained/lost events to ensure that the software responds correctly when the user receives a high priority notification (i.e. an incoming call).
3) Your application has to handle with care the memory in order to avoid crashes and runtime errors. In order to avoid errors is mandatory to test the application not only on the emulator but test it frequently also in the target devices.
4) When it’s possible allocate objects on the heap rather than on the stack.
5) Close gracefully the application when system resources are unavailable especially when you encounter Ram issues.
6) Always remember to set member HBufC variables to null after deleting them if your purpose is to re-allocate to the same variables.
7) Remember that function whit a trailing “C” on their name automatically put the object on the CleanupStack and that if you put manually these objects on the stack they will be present twice.
Remembr always thea Symbian OS constructor must never Leave. If a C++ construcor Leaves there is no way to cleanup the partially cosntructed object because there is no pointere to it.
9) When passing or returnig an object to a function ensure that if you take ownership of the object you delete it! Symbian uses the convetion that pointers in a method indicates transfer of owbershio to the caller while references indicate that the ownership of the passed object remains with the origina owner.
10) Take care when implementing framework classes in your application. You should always derive from the platform specific framework
provided.
If you enjoyed this article, you might also like...
Post comment
About MobileRevamp
The aim of this community is to share as much as possible information related to the mobile development using all the social networks and the new capabilities of the NET to make easier find updated contents and to create a deep feeling of connection between developers.
Updates
Archives
Recent Comments
- Giorgio Natili on Mobile Flash player 10.1 OR AIR 2.6 on Android?
- Patric on Mobile Flash player 10.1 OR AIR 2.6 on Android?
- AIR4Android on How to build your first AIR4Android application using FDT and Eclipse
- Tonsula on How to build your first AIR4Android application using FDT and Eclipse
- jbozabalian on Cross plarform mobile development
Adobe Mobile UGs
- Adobe Groups
- Australia MaDUG
- Boston MaDUG
- Brazil MaDUG
- Copenhagen MaDUG
- Dallas MaDUG
- India MaDUG
- Polish MaDUG
- Spain MaDUG
- UK MaDUG
Authors













