• No results found

Model-driven Development for a Treasure Hunt Android application

N/A
N/A
Protected

Academic year: 2021

Share "Model-driven Development for a Treasure Hunt Android application"

Copied!
9
0
0

Loading.... (view fulltext now)

Full text

(1)

Model-driven Development for a

Treasure Hunt Android application

Muram Faiz Ul

Subramani Uma Shankar

Marinescu Raluca

Eduard Paul Enoiu

alardalen University, V¨

aster˚

as, Sweden

{faizulmuram, shanumas, ralukutza, eduard.enoiu}@gmail.com

November 27, 2011

Abstract

The Android operating system has grown in the last few years and is becoming one of the most popular system for mobile devices. The amount of applications rises exponentially. By becoming more complex, the mobile applications development needs to be improved by using Model-driven development techniques. This report shows the advantages of Model-driven development for Android applications and specifically for the case of a Treasure Hunt application. An Eclipse plug-in was implemented to support the developer in creating a simple Android application.

(2)

Contents

1 Introduction 3 2 Development Description 3 2.1 Design Method . . . 4 2.2 Implementation . . . 4 3 Results 7 4 Conclusions 9

(3)

1

Introduction

A treasure hunt game is played by one or more players who try to solve different clues in order to find hidden articles, locations or places. Solving each clue takes the players to the next stage of the game, where they will get a new piece of the puzzle to solve. This continues until the player gets to the end clue that leads to the treasure. Treasure hunts come with different sets of rules. Some treasure hunts are a race to find the final clue and solve it. For others, each clue is worth points and sometimes offers the choice of completing one of two tasks. This game can be a fictional activity, but also a real life activity, played indoor or outdoor.

We have implemented a simple version of the game, played on an Android-based mobile phone [5]. During the treasure hunt the user will get multiple answers questions from different topics. Moving to the next stage of the game requires that the user answers correctly the current question. In case the user gives a wrong answer to a question, a hint will be provided. In our application the hints can contain textual, pictures, or audio features. The user performance in the game is implemented in form of a timer.

Based on the project requirements, in our project, we preliminary defined one language which is dedicated to the game description and one language to describe the mobile phone properties. Using these two models a correspond-ing treasure hunt game application based on Android OS was generated [2]. The project has been developed in Eclipse IDE.

This project started on the 5th of October 2011. Four students worked on the project, and each student had specific tasks to work on. We had regular meetings to talk about the progress of the project and to ensure that the individual tasks could be integrated in the project.

The rest of the report will deal with all aspect of developing this kind of application. In Section 2 we describe the overall development process. In Section 3 we present our results in emulation environment, before concluding the report in Section 4.

2

Development Description

There are a number of technological and organizational details in building and Android application using Model-driven Development (MDD) [4]. We defined our design details from the requirements definition as presented in the project proposal.

(4)

2.1

Design Method

Our initial plan was to define one language which was dedicated to the game description and one language to describe Android mobile phone properties. Using the game model and the phone model a corresponding treasure hunt application based on Android OS could be generated. However, we have iden-tified that the meta-model can be simplified in order to provide an efficient base for further development.

The platform for the Treasure Hunt game is a plug-in for the Eclipse IDE [3]. The architecture behind Eclipse provides a modular and easily customizable support for model-driven development of applications. During the design phase we have used the Android Development Tools (ADT) [1]. This factor made the development of the plug-ins as easy as possible.

Basis for developing Treasure Hunt plug-ins is the Eclipse Modelling Framework (EMF), which contains the ecore meta model. We decided to design the plug-ins starting from the game model and diagram. Acceleo is a technology included in the Eclipse Modelling Tools. We decided to generate source code from the specific domain model with the aid of a template.

In the plug-in theses technologies are used to generate a part of the An-droid application and build the structure for the transformation of the cre-ated ecore domain model into the Android based code. Therefore, we have divided the MDD Treasure Hunt application in three: Treasure Hunt Meta-Model, Transformation and generation plug-in, and Android application logic and UI.

2.2

Implementation

The result of this project is an Eclipse plug-in for Treasure Hunt- based Android applications. With this plug-in, the developer can generate the content by designing an ecore model based on the Game Model Ecore model. In Figure 1 the Game Model is depicted. The model has one root element named gamemodel. Every game created has a name and a variable number of stages. Every stage contains a questions, a correct answer, one or more possible answers. Also, we have defined some hints relating to the current stage. This hints can be of three types: text, audio, and image.

Meta-model should be registered before launching Acceleo transforma-tion. Source code used for registration of Ecore model (GameModel.ecore) is depicted in Figure 2.

The ecore model is part of the plugin that generates the Android Treasure Hunt application. This was done by implementing a template that transforms the game model, as depicted in Figure 3. The Acceleo transformation is used

(5)

Figure 1: Game Ecore Model

Figure 2: Registration of GameModel.ecore

to generate the strings.xml file that contains all the treasure hunt informa-tion. The generation plugin was designed as an action button for every game model created.

Figure 3: Acceleo MTL Transformation

The transformation rules for M2T are shown in Figure 3. “[module generateXML(’/com.mdh.se.treasurehunt/model/GameModel.ecore’)]” indi-cates ecore meta-model URI. Template structure starts with “[template pub-lic generateStrings(game : Game)]” and ends with [/template]; where ‘gen-erateStrings’ is a template name. Transformation rules are enclosed inside

(6)

‘template’ tags. The name of target file is specified in opening ‘file’ tag “[file ((’strings.xml’), false, ’UTF-8’)]”.

For retrieving contents of each stage, for loop is used. Information con-cerning each stage attribute is retrieved by using stage (dot) attributename. Each stage either contains image hint, audio hint or text hint. For retriev-ing correspondretriev-ing hint, if-elseif block is used which identifies that whether attributename is not null and not an empty string. Upon verification, corre-sponding information is printed.

Figure 4: Acceleo MTL Transformation

As depicted in Figure 4, we define every Treasure Hunt stage as a string resource. The game name is depicted as a string resource and the stages are an array of strings that can be referenced from the application. In our implementation a stage is a simple resource that is referenced using the value stages. As such we can combine stage resources with other simple resources in one XML file, under the resource element.

The Treasure Hunt application has, as depicted in Figure 5, a generic hierarchy that is improved with some specific information influenced by the model-driven approach. As a result, we differentiate between the application UI and interaction provider and the application resources. For simplification we use one activity for providing a screen with which users can interact in order to find the treasure. The activity is given as a window in which to draw its user interface.

Having generated the stages resources we can maintain them indepen-dently. As depicted in Figure 6, the stages are referenced easily during run-time by parsing every stage and using the question, answers, and hints information.

(7)

Figure 5: Text transformation result

Figure 6: Android Project Structure

3

Results

To debug and test our MDD application we have used the Android SDK for Eclipse IDE. Because of the absence of a physical device, we have used an

(8)

Figure 7: Stage Parser

Android emulator instance and Android Debug Bridge for managing the state of the emulator. Additionally, we have used LogCat for checking different running threads on the emulator.

In the current version of the application the user is able to manage the generation of the game model for a simple string resource structure. We have kept the MDD application complexity to a minimum because we are dealing with a device environment with limited resources. Therefore, we provide an efficient transformation and generation in order to offer the developer a simple way of building this kind of applications.

The project has met all of its main requirements and it should be noted that the development followed the standard practices in MDD and Android application development. Therefore, will not prevent any further expansion.

(9)

4

Conclusions

The goal of the project was to create a treasure hunt tool that generate from a domain model the content for Android applications. The goal was achieved by improving and efficiently developing an Android application based on a specific meta model. The part of the source code that is transformed only builds a part of the complete application source code. The other parts are generated automatically.

Future modifications could add functionalities like support for GPS lo-calization and better scoring results.

References

[1] Ed Burnette. Hello, Android: Introducing Google’s Mobile Development Platform. Pragmatic Bookshelf, 2nd edition, 2009.

[2] Google. Android development documentation : The developer’s guide http://developer.android.com/guide/, October 2011.

[3] Steve Holzner. Eclipse: A Java Developer’s Guide. O’Reilly & Associates, Inc., Sebastopol, CA, USA, 2004.

[4] Anneke G. Kleppe, Jos Warmer, and Wim Bast. MDA Explained: The Model Driven Architecture: Practice and Promise. Addison-Wesley Long-man Publishing Co., Inc., Boston, MA, USA, 2003.

[5] Victor Matos and Rebecca Grasser. Building applications for the android os mobile platform: a primer and course materials. J. Comput. Small Coll., 26:23–29, October 2010.

References

Related documents

In summary, using an ipsilateral technique in selected patients with well lateralized squamous cell carcinoma of the oral cavity or oropharynx reports clinical benefits, sparing

public class QuizActivity extends AppCompatActivity { private Button mTrueButton;.. private

Do a blank printable video scavenger hunt blank treasure maps treasure map with some halloween party game can generate a better known as many activities?. Get earth view maps is a

Teniendo en cuenta estos antecedentes, este estudio plantea como objetivo principal determinar los cambios en la composición en ácidos grasos, con énfasis en ácidos

"A Learning Tool for the ISO/IEC 29110 Standard: Understanding the Project Management of Basic Profile." In International Conference on Software Process Improvement

Applicable Standards for third grade history, geography, economics and civics are further addressed on pages 7 through 10 of this guide and connected with specific

From the data collected it was revealed that teachers’ expressed beliefs was not always consistent with their classroom practices; teachers traditional methods even though

Full integration with Ascentis Employee Self-Service allows Carrier Connect to transfer information collected directly from employees, bypassing the need for paper enrollment