Symbian Development Solutions
General tips
1. The 'symbian developer network' provides a large amount of information resources to help you compile applications for the Symbian OS Operating System. You should visit www.symbian.com/developer frequently to obtain the latest sdks, technical materials, coding examples and white papers. From the developer's Network
Website: • Symbian OS 'faq '(FAQ) Library. This is a valuable information library for developers and covers the most common design and coding problems. • Many white papers. This includes the Symbian OS C ++ coding standard. During the development of Symbian OS, Symbian has set several important coding habits and specifications. The White Paper on coding habits explains these habits to external programmers. By adopting these conventions and proven standards, you can benefit from the valuable experience gained from Symbian OS development by developing Symbian OS software. • Symbian OS Developer Library, standard API reference documentation, and Symbian OS guide. • Download application examples, application libraries, and optional system APIs that belong to the Symbian OS but are not necessarily installed on all mobile phones, enabling older versions of APIs on newer Symbian OS versions and other program tools. • Information about debugging tools and development tools. • The newsgroup Forum (www.symbian.com/#/leters/forum.html) enables you to get guidance from Symbian engineers and wider developer groups. There are a variety of forums, from specific issues for C ++ and Java, to hardware and Symbian signatures, etc.
All aspects of the work.
2. Register and subscribe to Symbian Developer Network journals (www.symbian.com/#/letters/index.html )--
This journal is published monthly by email, which is the best way to learn the latest news related to Symbian developers.
3. mobile phone manufacturers using Symbian OS also have their own developer projects. You should also register on their website to obtain the latest phone information and tips for a specific phone number.
4. Get certification! (Www.symbian.com/#/academy/index.html) the Symbian certified programmer certificate shows your employer that you are a qualified Symbian engineer and helps objectively evaluate the capabilities of your Symbian OS-related technologies.
5. The 'symbian signature' (Symbian signed) aims to promote the design of a variety of best examples of Symbian OS applications. Use Symbian
Signature applications comply with industry-recognized quality standards and meet the requirements of network operators for signature applications. Go to the 'symbian sign'
Website (www.symbiansigned.com) for more information about the Symbian signature.
6. In addition to Symbian and related producers, there is also an active developer community. Please visit www.symbian.com/#/about/trdprtysites.htmlto find links to third-party sdks with multiple names.
7. Finally, the number of Symbian OS publications is growing. The Symbian Publishing House (www.symbian.com/#/books/index.html) publishes a series of Symbian OS-related topics to help you easily write more reliable Symbian OS code.
Number of questions: 0 replies: 33
Modify, delete, report, reference, and reply
Add as a friend
Send private message
Online Chat
Ilyr
Level:
Availability score: zhongnong
Total technical score: 15
Total technical score ranking: 195480 published on: 19:25:53
1st floor score: 0
Design tips
1. The most important design trick is to separate the 'Engine 'code from the user interface (UI) Code and divide it into different modules. This design helps your program to be transplanted between different user interface systems. Symbian OS also uses this design. One of the methods is to make this distinction at the binary level. Place all non-user interface code in an independent engine. dll file. The Code related to the User Interface in your program can be linked to this. DLL file to access the engine to obtain its functions. Another method is to differentiate at the source code level. The application is generated as a single. app file, but the Code related to the 'engine' and user interface is allocated to different. cpp and. H files for management and debugging. This design can reduce the burden of porting code to a new user interface platform. Pure engine code can often run on any user interface platform without modification. This means that when porting to a new user interface, you only need to port and optimize a separate user interface layer.
2. Design with localized support in mind. Do not 'hardware' strings or texts into your source files-use the resource file mechanism provided by Symbian OS to store strings.
3. APIs that are explicitly supported and provided in the software development kit (SDK) and Symbian OS versions should be used. Using unsupported APIs or 'disrecommended' APIs will bring potential problems to your applications-Symbian will be retained in future versions
The right to modify or remove APIs that should not be used by external developers.
4. Do not assume that all 'system' files will appear on all phones. Manufacturers with the Symbian OS license can flexibly restructure their mobile phones. If the phones on the same platform are produced by different manufacturers, different support files may be included. For example, if the Speaker wants to write a fixed address for the audio clip to be played, this code will not guarantee good portability. You should at least consider how to handle the error status if your phone does not have this system file in the future.
Modify, delete, report, reference, and reply
Add as a friend
Send private message
Online Chat
Ilyr
Level:
Availability score: zhongnong
Total technical score: 15
Total technical score ranking: 195480 published on: 19:27:08
Second floor score: 0
Coding tips
The following are some tips you should remember when writing code.
1. Ensure that your application can respond to system shutdown events. In your Appui: handlecommandl () method, you must respond to eeikcmdexit (and any platform-related events, such as eaknsoftkeyback on Series 60.
2. Respond to external system events. Keep in mind that your application runs on a multitasking phone system and you need to focus on what you just got/lost, to ensure that you can respond correctly when a user receives a high-priority notification. For example, the incoming phone number may interfere with the running of your application. In this case, make sure that you have saved the system status and data (I .e: you need to take appropriate actions for standard "background" events-see SDK ). Generally, the system framework handles this problem and you do not need to take any special action-but make sure that you do not impede the normal operation of the system framework.
3. Memory Processing is an important topic to consider for Symbian OS. At this point, note that the phone number is sometimes different from the simulator. Therefore, before submitting your application to the "Symbian authentication signature" for testing, make sure that your program has been tested on the actual phone device.
4. Limited Memory stack space! Put objects in the memory heap as much as possible, instead of in the stack. One of the main causes of Kern-exec 3 exceptions (panic) is stack destruction/overflow.
5. An application exception (panic) indicates a certain error in your code. The following are some major and Common Errors:
• Forget to add non-object members and variables allocated to the heap to cleanupstack.
• Place member variables on cleanupstack-this must be avoided; Delete these variables in the destructor.
• 'Redelete'-for example, the destroyed object is not correctly POP () from cleanupstack, causing cleanupstack to try to delete it again. You can also delete an object after it is used, but forget to set its value to null, so that the Destructor tries to delete it again.
• Call a function with variables that may not exist in your destructor.
For example, the following code may cause an exception, because it is possible that your object has been destroyed before the memory is allocated, or the memory has been deleted in another place of the application, in this way, the isomeserver is null:
Cmyclass ::~ Cmyclass ()
{
Isomeserver-> close ();
Delete isomeserver;
}
Code should be written as follows:
Cmyclass ::~ Cmyclass ()
{
If (isomeserver)
{
Isomeserver-> close ();
Delete isomeserver;
}
}
• Call a function on a null pointer.
• The function calls another function, and the variables used are out of scope,
For example, send a stack variable to the callback of an asynchronous function. When the system resources are insufficient, it is very important to properly handle failures. The most restricted resource is the system Ram. Therefore, you need to properly handle insufficient memory. Using the 'two-segment constructor method' and the cleanupstack mechanism described below is essential and extremely important for this defensive programming.
7. cleanupclosepushl () is always used for classes with the "r" header and the close () method (). This ensures that the leave events are properly cleared when they occur. For example:
Rfile file;
User: leaveiferror (file. Open (...));
Cleanupclosepushl (File );
...
Cleanupstack: popanddestroy (& file );
You can also use the 'R' class of release () or destroy ().
Cleanupdeletepushl () and
Cleanupreleasepushl () to replace close ().
8. In addition, remember that the cleanupstack mechanism is scalable and can be used to effectively clear any objects in the face of all leave events. Even if you need to handle complicated cases, you should not ignore the formal cleaning mechanism. For more information about tcleanupitem, see the Symbian OS library documentation.
9. If you want to re-allocate resources to hbufc variables, you always set them to null after clearing them. The allocation or redistribution of hbufc resources may lead to the occurrence of leave events. As a result, the Destructor may attempt to delete nonexistent hbufc variables. Of course, this should be true for any variable allocated resources by the heap. It is even more common to use hbufc variables.
10. When you must use your own traps, do not ignore all errors.
Common encoding errors are:
Trapd (ERR, dosomethingl ());
If (ERR = kerrnone | err = kerrnotfound)
{
// Do something else
}
This means that other error codes are ignored. However, if you do not use the above model, you should use the leave mechanism to handle other errors:
Trapd (ERR, dosomethingl ());
If (ERR = kerrnone | err = kerrnotfound)
{
// Do something else
}
Else
User: Leave (ERR );
11. Do not delay the object pushl () to cleanupstack. All newly created objects (except member variables) should be immediately pushed into the heap
Stack. For example, the following method is wrong:
Void doexamplel ()
{
Csomeobject * myobject1 = new (eleave) csomeobject;
Csomeobject * myobject2 = new (eleave) csomeobject ;...
// Do something here with thevariables
Cleanupstack: pushl (myobject1 );
Cleanupstack: pushl (myobject2 );
// Do something more with the variables...
Cleanupstack: popanddestroy (2 );
// Myobject2, myobject1
}
Because the creation of myobject2 may fail, myobject1 cannot be cleared up. This should be done as follows:
Void doexamplel ()
{
Csomeobject * myobject1 = new (eleave) csomeobject;
Cleanupstack: pushl (myobject1 );
Csomeobject * myobject2 = new (eleave) csomeobject;
Cleanupstack: pushl (myobject2 );
...
// Do something here with the variables...
Cleanupstack: popanddestroy (2 );
// Myobject2, myobject1
}
12. Note that functions with names ending with uppercase letters C (such as newlc () will automatically place their objects in cleanupstack. You should not push these objects into cleanupstack by yourself. Otherwise, the object will be put into the stack twice. These functions end with C are useful when you create non-member variables and allocate memory to them.
13. "Two-segment constructor" is a key part of Symbian OS Memory Management. The basic principle is that constructor or destructor in Symbian OS should never have leave. If a C ++ constructor leave is used, the unfinished objects in the constructor cannot be cleared, because no pointer has been generated to point to this object. To this end, the constructl () function of symbianos only instantiates the object, and then calls the constructl () function of the object to instantiate the member data. Once constructl () occurs, the standard destructor is called to clear all member variables that have been successfully allocated. It is critical to use this design pattern in your code to prevent memory leakage. When writing each line of code, you should ask yourself: "Can this line of code have a leave ?" If the answer is "yes", you should consider "are all resources released ?".
14. Do not use the _ L () macro In the encoding -- instead, use _ random (). _ L () Since Symbian OS V5, It is 'unrecommended' (Deprecated). The problem is that it will call the tptrc (const ttext *) constructor, the constrlen () function is called to calculate the length of the string. Although this does not bring about Additional RAM overhead, it will occupy more CPU cycles during running. On the contrary, macro _ aggregate () directly creates an object that is fully instantiated during compilation, saving the CPU overhead for constructing tptrc. Of course, you should first consider whether hard-coded string constants should be used, because when you localized your program in the future, this constant type descriptor
(Descriptor) may need to be re-encoded.
15. When using a descriptor (descriptor) in function parameters, the base class should be used by default. In most cases
To pass the descriptor. For modifiable descriptors, TDES & should be used &.
16. When passing or returning an object in a function, make sure that you have the ownership of the object and you are responsible for clearing it! Symbian adopts the convention that the pointer in the function indicates that the ownership is transferred to the caller, and the reference indicates that the ownership of the transferred object is still in the original place.
.
17. Active objects is one of the important features of Symbian OS. Carefully study the SDK documentation and Symbian Developer Network White Paper to fully understand how it works. The following are some useful tips:
• No trap () is required in runl (). Active schedave itself traps the runl () function and calls cactive: runerror () When leave occurs (). • To this end, you should implement your own runerror () function to handle leave events from runl.
• Ensure that runl () operations are as short as possible. Long-running runl () blocks other active objects.
• Always implement the docancel () function and always call cancel () in the AO destructor ().
18. You should make full use of the active object Framework mechanism. For battery-powered devices, it is extremely inappropriate to perform polling closely in one cycle, resulting in high power consumption. Pay special attention to this when writing games. For more information, see Symbian.
Technical documentation for the developer network website (www.symbian.com/#/techlib/papers/porting_3d_games/xengames_paper.pdf ).
19. viewsrv 11 exceptions are a potential problem for busy programs (such as games. This exception occurs when viewsrv active object in your or any other program cannot respond to view server in a timely manner. The typical maximum response time is 10-20 seconds. FAQ-0900 has a detailed explanation, FAQ-0920 has practical skills on how to avoid such problems. Both can be obtained from the Symbian osfaq database on the www3.symbian.com/faq.nsf webpage.
20. You do not need to use hbufc: des () to enter an hbufc object. You only need to use the * operator to unreference hbufc objects (dereference ). This is especially useful when passing hbufc parameters to a function that accepts tdesc & (Recommended Practice above.
21. when using standard programs. when you use application ()-> openinifilelc (); API in your application UI class, make sure that the version number information is written to the stream. This allows you to create new streams in future new versions of the program, meaning that even if an end user installs a new version of your software in the future. an exception occurs when the correct configuration or stream is not found in the INI file.
22. Be careful when implementing the Framework class in your program. It should always be inherited from the provided platform-related framework classes. For example, for uiq, do not inherit your Appui class from ceikappui, but from cqikappui. The functions added by all application base classes (cqikappui, cqikapplication, and cqikdocument) support a wider range of frameworks to ensure that the application runs correctly.
Modify, delete, report, reference, and reply
Add as a friend
Send private message
Online Chat
Ilyr
Level:
Availability score: zhongnong
Total technical score: 15
Total technical score ranking: 195480 published on: 19:27:21
Third floor score: 0
Test tips
1. The most important test trick is to exit your program correctly when using an emulator instead of simply shutting down the entire simulator. In the debugging mode, memory and handle detection code are available before and after the application framework (applicationframework) closes the function,
When you exit the application, this code is called to detect whether memory leaks or legacy handles (such as R objects) occur.
For uiq programs, it is customary to provide an exit menu option in debug mode.
2. Another key trick is to ensure that the. PKG file contains the correct platform-related information before releasing your program. For more information about related platform strings, see the Platform SDK. FAQ count of Symbian OS on www3.symbian.com/faq.nsf
The FAQ-0853 in the database provides useful information.
3. When writing the. PKG file, make sure that "!" is used properly. : "" Syntax. In general, your application should be able to install and run from any drive on the end user's mobile phone. Only a very small number of files need to be placed in the C: "Drive (for example, the. ini file ).
Debugging tips
1. simulator debugging should always be used first. Most of the problems that occur simultaneously on the simulator and hardware will be much easier to debug using the simulator.
2. When writing and debugging new control classes, place ieikonenv-> wssession (). setautoflush (etrue) in the constructl () function of your Appui. This means that the GC draw command will be immediately displayed in the simulator, instead of the next flush window Server Client Buffer. Edit the wsini. ini file ("epoc32" release "winscw" udeb "system" data ") to ensure that the keyword flickerfreeredraw does not exist. This means that you can gradually run the draw code and see the effect of each line of code. However, make sure that this line of code is not left in the released software because it affects performance.
3. Run the leavescan tool on the source file at regular intervals. This tool can detect all functions that can be leave, report errors when their names do not end with L, and remind potential defects or negligence in the source file. This tool is very effective when you check which code should allow leave and make sure that this situation has been properly handled. See the FAQ-0291 In the Symbian OS FAQ database on www3.symbian.com/faq.nsf. Download this tool and learn more.
4. If your program is shut down normally due to memory leakage, you can convert the leaked address to the cbase * type in MS Visual Studio to view the type of the leaked object.
5. Recently, a new feature has been provided for Symbian OS developers: on-target debugging ). Although not all sdks and tools already have this feature, most recently released sdks and ides support this feature. If you can use this function, use it to detect any potential mobile phone hardware-related defects before releasing your program. For more information, see the SDK and IDE documentation.
6. Make sure that 'just in time' debugging is Enabled:
• Ensure that the macro "justintime 0" is deleted in the file "" epoc32 "data" EPOC. ini"
• Set the registry value as follows:
[HKEY_LOCAL_MACHINE "software" Microsoft "Windows NT" CurrentVersion "AeDebug]" userdebuggerhotkey "= DWORD: 00000000" Debugger "=" "C: "" apps "" metrowerks "" bin "" ide.exe ""-P % LD-E % lD "" Auto "=" 0 "20
7. Review error messages in % Temp % epocwind. Out.
8. Use all available development tools, including lint, leavesan, hooklogger, panix, and d_exc, to check memory leaks and other errors. These tools and other useful tools can be downloaded from the symbiandeveloper Network (www.symbian.com/#/downloads/tools.html ).
9. The FAQ-1344 teaches you how to diagnose and debug faults that violate the platform security (kerrpermissiondenied), which helps identify the permissions that your program lacks ).
Reference books
[1] Symbian Developer Network newsletter
Http://www.symbian.com/developer/faq/index.html
[2] Symbian OS FAQ Database
Http://www.symbian.com/developer/techlib/faq.html
[3] Symbian OS C ++ coding standards paper
Http://www.symbian.com/developer/techlib/papers/coding_stds/2003-01_SyOSCodStn.pdf#one
[4] Coding idioms paper
Http://www.symbian.com/developer/techlib/papers/coding_idioms/2002_10_09_codingSymbianOS.pdf
[5] Symbian Press
Http://www.symbian.com/developer/books
[6] Games writing paper
Http://www.symbian.com/developer/techlib/papers/porting_3D_games/XenGames_paper.pdf
[7] active objects paper
Http://nds2.ncsp.nokia.com/download? Asset_id = 11981; ref = Symbian
Or http://www.forum.nokia.com/main/1,,1_32_10_5,00.html
Developer Resources
Symbian Developer Network
Http://www.symbian.com/developer
Symbian Developer Network newsletter
Http://www.symbian.com/developer/newsletter.html
Symbian OS tools providers
Http://www.symbian.com/developer/downloads/tools_providers.html
Sony Ericsson developer world
Http://developer.sonyericsson.com/site/znch/home/p_home.jsp
Forum Nokia
Http://forum.nokia.com
Sun Microsystems developer services
Http://gceclub.sun.com.cn/NASApp/sme/controller/teclist? Tid = 01