The Mobile Library Experiment

To illustrate our approach to code generation in EP based on templates, supporting the generation of code for various platforms from the same EP model, and to provide an experiment in model-centric model-driven development, we devised the Mobile Library experiment. This builds an EP model of a mobile library application, designed to run on mobile devices, and then generates code for the Android and iPhone platforms from this EP model.

This page gives information on how to run this experiment. In particular, we show how to:

This experiment illustrates how EP can be used to describe a platform-variant family of applications. This is based on an infrastructure based on templates expressed in the Formal Template Language (FTL):

Importing the Example Project

Having installed Democles, download the MobileLibrary example:

MobileLibrary-example.zip

Import it into your workspace by choosing File→Import..., then selecting the General→Existing Project into Workspace option. After selecting the downloaded project archive and clicking Finish, the project will be available in the workspace.

Pre-generated Sources

We make pre-generated sources of this example project available for the benefit of those that want to try out the application or that want to see the generated ObjC or Java source code, without having to install Democles:

The MobileLibrary

The MobileLibrary application is a proof-of-concept mobile application that allows searching a virtual library. Using FTL-based code generation, it can be run on two popular mobile platforms:

The MobileLibrary application comes with a small database of books. To see all of them, perform a search for ISBN "1234". Three user accounts have been included: "M01", "M02" and "M03", each having as password "1234".

Running the Android version

Prerequisites

In order to be able to test the generated Android application,

  1. the Android SDK must be installed,
  2. the SDK Platform Android 2.2, API 8 (latest revision) must be installed, and
  3. an emulator image using the "Android 2.2 API Level 8" target must be created, or a compatible physical Android device must be connected in debugging mode.

Generating code and running it

After the example project has been imported, follow these steps:

  1. Open the context menu of the MobileLibrary project and choose Export.... Then choose Other→Democles Project using FTL. Click Next.

  2. Make sure the MobileLibrary project is chosen, and the ANDROID target platform is selected:

    Click Next.

  3. Observe that for each Domain marked as a "Binding Domain", a corresponding template subcatalogue has been selected:

    Concepts in an EP Domain can only be mapped to implementations in their selected template subcatalogue. Click Next to proceed.

  4. The next wizard page shows the mapping of EP model concepts to template catalogue concepts:

    A working configuration is included with the example project. Choose a destination folder for the generated code, then click Finish.

    Note: The most convenient option is to choose your Eclipse workspace as the output folder, in which case you won't need to import the project in the next step.

  5. Import the generated project into the workspace of an Eclipse installation configured with a working ADT (Android Development Tools) plugin and Android SDK using the File→Import...→Existing Projects into workspace wizard.

  6. Run the imported project by choosing Run As→Android Application from its context menu. The application's screens look as follows:

Running the iPhone version

Prerequisites

In order to run the generated iPhone application, Xcode must be installed.

Generating code and running it

After the example project has been imported, follow these steps:

  1. Open the context menu of the MobileLibrary project and choose Export.... Then choose Other→Democles Project using FTL. Click Next.

  2. Make sure the MobileLibrary project is chosen, and the IPHONE target platform is selected:

    Click Next.

  3. Observe that for each Domain marked as a "Binding Domain", a corresponding template subcatalogue has been selected:

    Concepts in an EP Domain can only be mapped to implementations in their selected template subcatalogue. Click Next to proceed.

  4. The next wizard page shows the mapping of EP model concepts to template catalogue concepts:

    A working configuration is included with the example project. Choose a destination folder for the generated code, then click Finish.

  5. Open MobileLibrary.xcodeproj in the generated Xcode project on a system that has the iPhone SDK and Xcode installed.

  6. Choose Project→Set Active SDK→iPhone Simulator 3.x in Xcode to set the used iPhone SDK version to one that is available on your system.

  7. Run the imported project by clicking Build and Go in Xcode's toolbar. The application's screens look as follows: