Wednesday, August 13, 2008

Bug Free Application in Symbian

Here are few tips that we should consider while coding for Symbian applications. These suggestions are based on my experience while doing Symbian Development which will be a bug free application.
  • Make sure that the applications we develop responds to system shutdown events.
  • Make sure that the application is responding to all the incoming system events, since the application is operating in multitasking environment. So analyze on the highest priority tasks and our application should respond to that event.,
  • Memory handling is the first and foremost thing we need to consider for a bug free application. Check all the memory allocation has been freezed and deleted at the destructor and this will save your application from crashing and runtime errors. Whether the application is tested in emulator or target device, it is mandatory to avoid those errors.
  • Try to allocate the objects on the heap rather than stack.
  • HBufC variables should be set to NULL after deleting them, if your purpose is to reallocate to the same variables.
  • The function with a trailing "C" is automatically put their object on the CleanupStack and if you put manually put these objects on the stack, then this will be presented twice.
  • Do remember that Symbian OS constructor will never leave. If a C+\+ constructor leaves, then there is no way to clean up the partially constructed object because there is no pointer to it.
  • Always remember to not to use hard code strings or literals in your application. Instead use the resource files to provide the strings.
  • Do not use deprecated API's, as it may work with emulator and not with Target Device and this will lead to a problem.
  • Some of the application will throw a "System Error" without throwing the Error code or panic number. This might be generated mostly because the application tried to read from resource file or Graphics file but could not. Make sure that, you have entered proper values and statements/paths in the Resource file or Graphics File.
  • Finally try to delete the unwanted or unused variables and try to remove all the warnings.

No comments: