The home page of www.series60.com reads: "The Series 60 Platform,
built on the Symbian OS, is currently the leading smartphone
platform in the world." Many readers that remember the first IBM PC
with a color monitor and MS-DOS probably
get dizzy when reading the feature list
of any smartphone
based on Series 60. And many developers who wrote
C code for that IBM PC get dizzy as well after realizing how complex
an apparently simple Series 60 application in C++ can be. This article
describes how custom-made generators can help Series 60 developers
write applications more rapidly with less tedious work.
The reference development environment for this article is the
Series 60 2nd Edition SDK for Symbian OS, Supporting Feature Pack 2,
For C++, Supporting Metrowerks CodeWarrior. This SDK is available
after registration on www.forum.nokia.com. It contains
several example applications, one of which is the Form Example
used for the sample custom-made generator described in this article.
The Form example application, also referred to as AknExForm, demonstrates
how to use the forms and editor controls available on the Series
60 Developer Platform.
The class diagram of this application is shown in the figure below,
taken from the SDK documentation.
In a way, the above class diagram defines a class, or macroclass, of
form applications. The custom-made generator here described
(hereinafter referred to as SoProMach/S60FormGen)
produces complete applications belonging to this macroclass.
The original AknExForm contains all the know-how necessary to
build different types of forms, such as single-page vs. multi-page, or
view-or-edit vs. always-edit. The sample custom-made SoProMach/S60FormGen
produces one-form or multi-form, single-page, view-or-edit
form applications. The first sample application generated with SoProMach/S60FormGen is
the one-form application shown in the following screenshots of the
Series 60 emulator running the application.
This generated application is a subset of AknExForm.
Figure 2 shows the icon of the generated application. Figure 3 shows the
available options (All editors, Exit) for the "Edit" application. Figures 4
and 5 show the form in view and edit mode respectively. Data input is checked
on entry by means of appropriate editors, according to the type
of data being input (plain string, numeric range, date, time, duration,
secret code).
How can a developer produce the application above with SoProMach/S60FormGen? How can
the application form, or forms, be designed and described?
SoProMach is a purely textual software production machine, and so
are the custom generators built on top of it.
Therefore to "configure" the generation job, the
developer writes one or more textual files. Several formats are accepted
by SoProMach: Somusar/EF (see below), XML, CSV,
or ad-hoc domain-specific languages (DSL).
For this specific SoProMach/S60FormGen generator, the sole
input required is an EF (entity file) description as the one
shown below.
(Note by the way that SoProMach-based
generators can be integrated with any IDE providing support for external tool
invocation: see examples of
integration with Eclipse and
with Visual Basic Express 2005 Beta).
Readers unfamiliar with EF files may view different examples in different
contexts, such as the entity files of
the Eclipse-driven Java/JSP/DAO Struts generator.
The simplified AknExForm application described in the previous paragraph
is generated and built in a
completely automatic fashion starting from "akn_ex_form.ef": no hand-edits
whatsoever are required to build it. In fact, SoProMach/S60FormGen itself
runs the commands of the build environment, as shown in the next picture.
The careful reader might have noticed that generating and
building the application required about twelve seconds, including
compiling, linking and deploying the application, which is then
ready to be run in the emulator.
Now that the software production mechanism is in place, it is easy
to create new applications by simply creating new EF files, as the ones
shown below.
When the EF files are ready, re-running SoProMach/S60FormGen results in two new
applications. The 3-form application is shown in the screenshots below.
Note the cascading "Biz" menu, as configured in "three_forms.ef" by means
of parameter UI.biz.cascade_menu set to "true". The next figures show
the Biz form
in edit and view mode, and the Friend form in view mode.
When the forms of the applications are ready, the developer
can extend the generated application as desired. Several options
would be available that go beyond the scope of this article. Here we
will mention only that both IDE-oriented and text-editor developers
will be able to extend the application in their preferred way. In particular,
users of Metrowerks CodeWarrior
can import the project directly into the IDE, as the following picture shows.
The links to the code files generated by SoProMach/S60FormGen for the three
applications are listed below. The code looks very similar to the
code of the original AknExForm example application.
A measure of the efficiency of SoProMach/S60FormGen can be given by the output-to-input ratio:
the higher the number, the more efficient is the generator. Under this respect,
the measure in terms of files is given by the
number of generated files divided by the number of input files, which is
20 / 1 = 20
Alternatively, this measure can be calculated in terms of lines of code (LOCs).
The overall number of LOCs for the three applications yields
SoProMach-based generators utilizing EF files produce software
by means of so-called Software Molds. Molds can range in complexity
from very simple to very complex. SoProMach/S60FormGen provides some good examples of software
molds.
The mold for generating the <<AppName>>Document.cpp
files of the applications
is very simple. In fact, it is just a one-file template
(code/moldkit/UI/mold18-Document.cpp/file.hdr)
The structure of the <<AppName>>SaveForm.cpp files
is more complex, and the corresponding mold
reflects this complexity. Note that the mold's complexity is roughly equivalent
to the internal complexity of a compiler, the major difference being
that SoProMach allows to build "open" compilers, in that they
are made up of text files that might be adapted and extended as
required.
A first block of
<<AppName>>SaveForm.cpp
code is produced with
a file.hdr
introduction. Then, two molding steps are required, described below.
Finally, a trailing block is produced with
file.trl.
The intermediate steps produce leading and trailing blocks
of code for each step and for each form defined in the input EF file,
generating additional code for each member of the form.