Compact Framework: Lessons learned
We're in the middle of an integration project for our customer. The project involves integration of the NAVMobile product with the customer's ERP system. The project involves custom .NET and Compact Framework development and I decided to share some of the lessons that we've learned (again and again).
I'm targeting Compact Framework here, however most of the hints are platform agnostic.
Lessons learned(Performance related):
- Test your application with real-life data. Plan and test your application for higher data volumes than initially expected. Perform load and stress tests. Strive to test with real-life data. Ask your customer to assist in creating near real-life data samples for you. Plan for the most pessimistic case. Have your real-life data samples and then tune your database(add indexes)
- Optimize xml size. If you're using xml for data exchange and you're in control to define the xml schema - minimize the xml size. Strip blanks and use shorter tags.Use XmlReaderSettings and XmlReader.Create to create optimized XmlReader.
- Perform multiple updates in a single transaction. Group database updates in a single database transaction. Otherwise every single database update is performed in a separate automatically created transaction. The transaction management costs CPU cycles!
- Use DataReaders and SqlCeResultSet if possible. Avoid using Datasets - they are slower and eat a lot of memory. Use LIMIT/TOP clause in SELECT statements to limit the records returned by the database engine. Limit the records rendered in the UI. Users often do not need to see several thousand items on their PDA's screens.
- Compress data, when crossing application boundaries. Consider compressing data sent over the wire. However, write down some performance metrics, before assuming that the compression is a solution for your case. The compression is expensive in terms of CPU cycles. Compressing small data volumes may cause overall performance degradation.
- Carefully, plan for caching
- DO NOT ASSUME ANYTHING!
Caching expensive resources in memory for fast access is a valuable technique.
Create WebServices proxies only once and use'em multiple times. The same approach is useful when using XmlSerializer. Preserve references to resources "created" through reflection. For example do not invoke Type.GetMember every time. Invoke it once, preserve the references to the MemberInfo returned and use it many times.
The mobile CPU power and memory are limited, so be careful!
Test, write down some metrics and then start optimizing. Use RPM to get more realistic idea about your application.
Minimize boxing and avoid creation of massive numbers of objects. Take time to understand the Compact Framework Garbage Collector in depth. Get Mobile View to launch RPM easily.
Lessons learned(Usability):
- Make buttons bigger.
Think the users like to use their fingers to tap the screen - Minimize tapping and clicking
Try to predict user behaviour and intentions. Think instead of the user. Develop "smart" UI - populate default values based on current context. Minimize virtual keyboard usage. Plan for task oriented UI to focus the UI toward single task completion.
Links:
Compact Framework performance hints
Compact Framework performance related resources
No comments:
Post a Comment