Simpler and cleaner code

Retweet Share on Facebook

It’s great to see news this week of one outcome of  Symbian’s commitment to keep on improving developer experience.  As announced on the Symbian Developer Network:

>>>>>>>

The new EUserHL Core Idioms library delivers:

  • LString, a string class that handles its own buffer management and cleanup
  • LCleanedupX and LManagedX, a set of cleanup management helper templates
  • CONSTRUCTORS_MAY_LEAVE, a helper macro that enables single-phase construction
  • OR_LEAVE, a helper macro to cleanly convert error-returning code into leaving code.

The necessary header files for exploiting the new code idioms library are supplied in a header EUserHL.h, supported by a DLL, EUserHL.DLL, and an EUserHL.SIS installable package, available for all Symbian OS v9-based devices.

This makes Symbian OS easier for programmers by:

  • Making it simpler and cleaner to write correct cleanup-safe code, with fewer lines of code than before;
  • Making an elegant, leave-safe implementation of the widely-used C++ RAII (Resource Allocation Is Initialization) idiom available for Symbian OS programming;
  • Making it simpler and cleaner to write code involving arbitrary-length strings without choosing magic numbers for their length, and variable-length strings without performing manual memory management.

Using the Core Idioms library has a pervasive impact on line-of-code count and on simplicity and cleanness. That’s great when you write the code, and awesome when you come to maintain it.

The Core Idioms library delivers these improvements by exploiting the mapping of Symbian OS User::Leave() onto C++ throw, introduced in Symbian OS v9 and by relieving the application programmer of much explicit responsibility for memory management for strings and cleanup.

Idioms define the style by which programmers use an OS, and therefore have a pervasive ease-of-use impact in normal Symbian programming by programmers working at all levels of the software stack.

Use of this library is recommended for all new code. Only if you know you can do better by managing your own memory with traditional descriptor APIs, cleanup stack idioms, and two-phase construction, should you continue to use the traditional Symbian OS features instead of Core Idioms…

In conclusion, the EUserHL Core Idioms library allows:

  • Experienced Symbian C++ developers to write robust and compact string-handling code with semi-automated exception handling;
  • New Symbian C++ developers to use Symbian OS exceptions, the cleanup stack and descriptors more easily, with fewer programming errors and more rapid application development.

For further information, and to obtain the new library, see the Downloads section of the Symbian Developer Network page.

(This is just the outcome of the first phase of the “Core Idioms” project: there’s lots more in the pipeline.)

Posted: March 28, 2009 at 11:01 pm

Last updated: February 5, 2010 at 6:42 pm

Categories: Tech Themes

Tags: ,

Short Link: http://wp.me/pqgpU-9q