14
Speed delivery of Android devices and applications with model-driven development Skill Level: Intermediate Beery D. Holstein ([email protected]) Senior Manager, Rhapsody Product Development IBM 06 Jun 2011 Along with the Android software stack rapidly gaining market share for applications on a variety of devices, embedded product designs are becoming more complex and product lifecycles are shrinking. Efficient development has become essential. This article presents several situations where using model-driven development (MDD) can help developers speed the delivery of Android-based devices and applications. The Android software stack is rapidly gaining market share for applications on a variety of devices, such as smart phones, tablets, televisions, and in-vehicle information and entertainment systems. The diversity of market segments, an explosion in the number of new devices, and the demands of heterogeneous users are forcing device manufacturers and application providers to introduce high-quality, innovative products in shorter time frames. At the same time, shrinking development budgets and a tough economic environment make efficient use of development resources a critical necessity. With embedded product designs becoming more complex and product lifecycles shrinking, efficient development has become essential. The emergence of model-driven development (MDD) has made it possible to accelerate the development process. With MDD, software engineers can more clearly understand and analyze requirements, define design specifications, test system concepts using simulation, and automatically generate code for direct deployment on the target hardware. This article presents several scenarios where using MDD can help developers speed the delivery of Android-based devices and applications. About the Android stack Speed delivery of Android devices and applications with model-driven development Trademarks © Copyright IBM Corporation 2011 Page 1 of 14

Speed delivery of Android devices and applications with model-driven development

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Speed delivery of Android devices and applications with model-driven development

Speed delivery of Android devices and applicationswith model-driven developmentSkill Level: Intermediate

Beery D. Holstein ([email protected])Senior Manager, Rhapsody Product DevelopmentIBM

06 Jun 2011

Along with the Android software stack rapidly gaining market share for applicationson a variety of devices, embedded product designs are becoming more complex andproduct lifecycles are shrinking. Efficient development has become essential. Thisarticle presents several situations where using model-driven development (MDD) canhelp developers speed the delivery of Android-based devices and applications.

The Android software stack is rapidly gaining market share for applications on avariety of devices, such as smart phones, tablets, televisions, and in-vehicleinformation and entertainment systems. The diversity of market segments, anexplosion in the number of new devices, and the demands of heterogeneous usersare forcing device manufacturers and application providers to introduce high-quality,innovative products in shorter time frames. At the same time, shrinking developmentbudgets and a tough economic environment make efficient use of developmentresources a critical necessity.

With embedded product designs becoming more complex and product lifecyclesshrinking, efficient development has become essential. The emergence ofmodel-driven development (MDD) has made it possible to accelerate thedevelopment process. With MDD, software engineers can more clearly understandand analyze requirements, define design specifications, test system concepts usingsimulation, and automatically generate code for direct deployment on the targethardware. This article presents several scenarios where using MDD can helpdevelopers speed the delivery of Android-based devices and applications.

About the Android stack

Speed delivery of Android devices and applications with model-driven development Trademarks© Copyright IBM Corporation 2011 Page 1 of 14

Page 2: Speed delivery of Android devices and applications with model-driven development

Android is a software stack for mobile devices. It includes an operating system,middleware, and key applications (see the link to "What is Android" in Resources formore information). The Android SDK provides the tools and APIs necessary to begindeveloping applications on the Android platform, using the Java programminglanguage. These include a device emulator, tools for debugging, memory andperformance profiling, and a plug-in for the Eclipse development environment.Figure 1 shows the major components of the Android operating system within theapplication framework, libraries, Android runtime, and Linux kernel.

Figure 1. Major components of the Android software stack

Larger view of Figure 1.

Android software developers can be classified into two kinds: platform vendors andapplication developers.

• Platform vendors are the companies that combine software and hardwareto produce the actual devices. These devices serve as the hosting

developerWorks® ibm.com/developerWorks

Speed delivery of Android devices and applications with model-driven development Trademarks© Copyright IBM Corporation 2011 Page 2 of 14

Page 3: Speed delivery of Android devices and applications with model-driven development

environment for smart device applications, at least for the "on-device"portion of the application. (Many such applications also include a servercomponent.)

• Application developers are the organizations that create the software thatcalls upon the services exposed by the Android device ("the platform"). Inthis categorization, it is important to note that platform vendors frequentlywant to deliver their devices preloaded with a set of applications so thatthe devices are useful immediately, as delivered Consequently, it iscommon for platform vendors to develop applications and to ensure thatapplications developed by third parties work properly with the device thevendor intended to provide.

Model-driven development for embedded systems

Models are used to represent a system at higher levels of abstraction, whilepromoting consistency, accuracy, and precision. Because the models are at a higherlevel of abstraction than the source code, they permit the construction of views thatcan answer specific questions about the functionality, structure, or behavior of thesystem or software. It is important to distinguish between "pictures" and semanticmodels. A disconnected picture showing a vague concept can be useful, but asemantically deep model that represents details of the relevant aspects of thesoftware can provide huge benefits to the developer and other stakeholders.Specifically, good models are connected to the software so they always representthe actual content of the source, which increases consistency across views andimproves communication of the software.

The most popular modeling language in the world is the Unified Modeling Language(UML), which has been in use for over a decade with huge success. UML is basedon a relatively formal definition, known as a metamodel, which gives the languageboth precision and scope. UML diagrams provide a view of system aspects bygraphically representing the model elements and their relationships. A model thatfocuses on the functionality and behavior of the application can be used to generatea fully executable application that is ready to be deployed on a specific target,RTOS, middleware, and communication mechanisms (see the two books by BrucePowell Douglass cited in Resources.

Note:IBM® Rational® Rhapsody® is a visual development environment for systemsengineers and software developers who are creating real-time or embeddedsystems and software. The author uses this software to demonstrate some of theconcepts involved in model-driven development (MDD) in convergence with theAndroid SDK for this article.

ibm.com/developerWorks developerWorks®

Speed delivery of Android devices and applications with model-driven development Trademarks© Copyright IBM Corporation 2011 Page 3 of 14

Page 4: Speed delivery of Android devices and applications with model-driven development

Converging MDD with Android software development

MDD provides several ways to speed up the development of Android devices. Thisis accomplished through a deeper understanding of Android applications and theAndroid framework, by updating and creating Android applications, and byconnecting the software development to requirements, testing, and planning. Thesebenefits are leveraged from within Eclipse, which is the primary developmentenvironment for Android hosts, both the Android SDK and the MDD tools forAndroid.

The Android API as part of the model

UML is a powerful language for modeling, but it provides only a generic template ofinformation for systems. Over the years, UML has spawned a number of variants,known as profiles, for specific areas of development. Modeling closer to the relevantdomain reduces ambiguity and provides a clearer view of the design intention forcolleagues and customers.

To facilitate development in the Android domain, the Android Framework is beingvisualized through a model library that consists of the various packages, classes,and public interfaces found in the Android API and through a profile thatencapsulates some of the main Android building blocks as stereotypes. Developerscan drag elements from the profile and from the model library into UML diagrams.This enriches the design with API use and guides Android application generationfrom the model. Figure 2 shows a UML profile and a model library based on theAndroid API. The profile and the model library are used during visualization,creation, and update of Android applications from within the MDD tooling. Thisenables developers to use the Android terminology in designs.

Figure 2. The Android API visualized through a model library and a UML profile

developerWorks® ibm.com/developerWorks

Speed delivery of Android devices and applications with model-driven development Trademarks© Copyright IBM Corporation 2011 Page 4 of 14

Page 5: Speed delivery of Android devices and applications with model-driven development

Developing an Android device involves new code, modifications to existing code,existing code that does not change, and third-party libraries. Existing code andthird-party libraries can be visualized in the model, resulting in a graphicalrepresentation of their structure and relations using UML class diagrams. Suchvisualization allows developers to understand different aspects of an existingAndroid application and to communicate them to various stakeholders, such ascustomers, managers, architects, other developers, and testers. They can alsoextract documentation from the model, thereby providing a different aspect ofcommunication.

During visualization of an application (and parts of its associatedAndroidManifest.xml file), the Android profile and model library are automaticallyused to identify Android-specific elements, such as activities and services. Thisresults in visualizing not only the application itself, but also its relationship to and itsuse of the Android API, as shown in Figure 3. Also shown is how MDD is integratedas a plug-in for the Eclipse environment (see the link to Paul Urban's article inResources), facilitating modeling, coding, and simulation alongside the AndroidDevelopment Tools (ADT).

Figure 3. Visualizing the structure and algorithm of an Android application

ibm.com/developerWorks developerWorks®

Speed delivery of Android devices and applications with model-driven development Trademarks© Copyright IBM Corporation 2011 Page 5 of 14

Page 6: Speed delivery of Android devices and applications with model-driven development

Larger view of Figure 3.

In addition to providing graphical representation, MDD tools can depict execution ofthe application inside the graphical environment, which enables a betterunderstanding of the application's runtime behavior. Figure 4 shows how the runtimeinteractions between elements in an Android application that was instrumented witha code agent are automatically captured during its execution. The interactions arecaptured to a UML sequence diagram in which the vertical lines in the sequencediagram are elements from the Android application, and the horizontal lines showthe invocation of operations between elements. By showing the higher-levelabstraction of interactions between several elements in the Android application, theruntime behavior of an application is better understood and better communicated tovarious stakeholders.

Figure 4. Graphical environment provides insight into runtime behavior

developerWorks® ibm.com/developerWorks

Speed delivery of Android devices and applications with model-driven development Trademarks© Copyright IBM Corporation 2011 Page 6 of 14

Page 7: Speed delivery of Android devices and applications with model-driven development

Larger view of Figure 4.

Creation and updating

It is of very little practical value to have diagrams that are not directly connected tothe source code. Experience has clearly shown that having two representations ofthe system semantics, one in the model and the other in the code, quickly divergesso that the model and the code no longer match.

Starting with a fresh model or from a model used to visualize an existing Androidapplication, a matched Eclipse-Android project is created by the MDD plug-in, andthe project is populated with code generated from the model. This includes the staticportion of the models (for example, packages, classes, and operations) and thebehavior modeling (state machine). During this process, the Android profile andmodel library are automatically used to create some of the "glue" code needed toconnect the user code to the Android framework.

Figure 5 shows code generated from a structural model representation. Asdevelopers change the model, the source code is automatically updated. Similarly, ifthe source code is updated, the model is automatically changed to reflect the newsource code contents. This ability to associate the model code associativitypromotes agility, because the developer can choose to work either in the model or inthe source code, and synchronicity between the two is automatically maintained.

Figure 5. Code generated from the structural model

ibm.com/developerWorks developerWorks®

Speed delivery of Android devices and applications with model-driven development Trademarks© Copyright IBM Corporation 2011 Page 7 of 14

Page 8: Speed delivery of Android devices and applications with model-driven development

Debugging and testing

Although defects are most likely introduced early in the process, they are often foundonly later on. Moreover, the cost for repairing defects goes up exponentially the laterthey are discovered. As a result, the challenge is how to find defects closer to thetime that they are introduced. If the model correctly depicts the intended functionalityand behavior of the application, the model can be brought to life and used to enableearly testing and debugging at the model level of abstraction.

In Figure 6, an Android simulator is used to execute an application generated from amodel. You can simultaneously see the active state highlighted in UML state charts(created by the developer and used earlier in generating the application) and viewthe UML sequence diagrams that were automatically generated during execution.You can then compare the sequence diagrams to the application's expectedbehavior, so you can validate proper design operation. You can also compare theautomatically generated sequence diagrams to those from a previous execution ofthe application to identify changes in behavior that might indicate regressions. Amodel-based testing (MBT) tool can further use the automatically generatedsequence diagrams to execute them automatically, thus both driving and monitoringtesting.

Figure 6. Debugging can be done at the code level and model level

developerWorks® ibm.com/developerWorks

Speed delivery of Android devices and applications with model-driven development Trademarks© Copyright IBM Corporation 2011 Page 8 of 14

Page 9: Speed delivery of Android devices and applications with model-driven development

Larger view of Figure 6.

Collaboration

Developing Android devices and applications can involve managing host systemdevelopment, legacy application maintenance, hardware development, and more.Managing the integration of these different domains introduces complexity andrequires that a holistic view of the architecture be available to development teamsworking independently on these different domains. The complexity of Androiddevices leads to increasing challenges in managing joint development lifecycles,testing sequences, and rollouts, and in monitoring and managing these systemsafter they are delivered. The challenge is further expanded by the large number ofdistributed teams, which often include agencies, contractors, OEMs, and suppliers.

Continuous validation and verification is fostered by combining requirements,models, quality management, and project monitoring, as shown in Figure 7. Themodels are made centrally accessible to the entire team and become the source ofthe entire design. A demo on YouTube (see references) shows how Rational TeamCenter is leveraged for project planning and monitoring.

Figure 7. Collaboratively managing delivery of a smart device or application

ibm.com/developerWorks developerWorks®

Speed delivery of Android devices and applications with model-driven development Trademarks© Copyright IBM Corporation 2011 Page 9 of 14

Page 10: Speed delivery of Android devices and applications with model-driven development

For example, as Figure 8 shows, MDD can be used to better understandrequirements by visualizing them in the model. The requirements are stored in themodel, and their relationship to design elements and test cases can be created,thereby helping to provide traceability information within the model. This, in turn, canbe used during testing to produce requirements a coverage matrix and reports. Theinformation from the requirements, such as the ID or specification, can beautomatically generated into the Android application code to enable traceability fromrequirements, design in the model, and implementation in code.

Figure 8. Requirements as part of the model

developerWorks® ibm.com/developerWorks

Speed delivery of Android devices and applications with model-driven development Trademarks© Copyright IBM Corporation 2011 Page 10 of 14

Page 11: Speed delivery of Android devices and applications with model-driven development

Larger view of Figure 8.

Conclusions

Combining MDD capabilities with the Android development environment can helpimprove productivity, as well as time to market, plus reduce costs. Aside fromproviding a convenient single environment for both Android coding and modeling, itoffers developers visual specification of design requirements. Moreover, theframework can be used to visualize existing Android applications, thereby offeringinsight into their structure and behavior. The use of models that connect therequirements, design, and code also simplifies documentation and enables thedocument to be automatically generated.

After the model has been created within the Android development environment,Android applications can be automatically delivered. In addition, the model can beused to execute the design, providing validation and allowing defects to bediscovered early in the design's lifecycle. This execution also offers automatedsoftware unit and regression testing for improved quality of code. The integratedenvironment is also a vital factor in enabling collaboration among distributed teamsand across development organizations.

ibm.com/developerWorks developerWorks®

Speed delivery of Android devices and applications with model-driven development Trademarks© Copyright IBM Corporation 2011 Page 11 of 14

Page 12: Speed delivery of Android devices and applications with model-driven development

Resources

Learn

• Cited in this article:

• Krasner, Jerry. What Do You Do When the Horse You're Riding DropsDead? Why Model Driven Design is Emerging as a Preferred BestPractice. A white paper published by Embedded Market Forecasters, adivision of American Technology, Inc. (2007).

• What is Android? Android Developers website. The Android Architecturediagram in Figure 2 is from the Android Open Source Project and usedaccording to terms described in the Creative Commons 2.5 AttributionLicense.

• The Eclipse Foundation.

• Getting Started with UML, UML Resource Page, Object ManagementGroup website.

• Douglass, Bruce Powell. Real-Time UML Workshop for EmbeddedSystems. Newnes (2006).

• Douglass, Bruce Powell. Real Time UML: Advances in the UML forReal-Time Systems (3rd Edition). Addison-Wesley Professional (2004).

• Urban, Paul. Combining Code Development, Modeling, and Simulationwith Eclipse, Dr. Dobb's Journal (October 2009).

• To learn more about using Rational Rhapsody Developer for collaborative,model-driven development for embedded systems, start with these overviews:Introduction to Rational Rhapsody, the Rational Rhapsody Developer productpage, and the Rational Rhapsody page on IBM developerWorks. Explore thevarious versions, too:

• IBM® Rational® Rhapsody® Architect for Software, a visual developmentenvironment for embedded systems and software

• IBM® Rational® Rhapsody® Architect for Systems Engineers

• IBM® Rational® Rhapsody® Designer for Systems Engineers

• IBM® Rational® Rhapsody® Developer edition. This edition is required forEclipse users and editions are available to create specialized projects in C,C++, Java, and Ada languages.

• Visit the Rational software area on developerWorks for technical resources andbest practices for Rational Software Delivery Platform products.

developerWorks® ibm.com/developerWorks

Speed delivery of Android devices and applications with model-driven development Trademarks© Copyright IBM Corporation 2011 Page 12 of 14

Page 13: Speed delivery of Android devices and applications with model-driven development

• Stay current with developerWorks technical events and webcasts focused on avariety of IBM products and IT industry topics.

• Attend a free developerWorks Live! briefing to get up-to-speed quickly onIBM products and tools, as well as IT industry trends.

• Watch developerWorks on-demand demos, ranging from productinstallation and setup demos for beginners to advanced functionality forexperienced developers.

• Watch the Rational Solution for Android mobile application development demoon YouTube.

• Improve your skills. Check the Rational training and certification catalog, whichincludes many types of courses on a wide range of topics. You can take someof them anywhere, any time, and many of the "Getting Started" ones are free.

Get products and technologies

• Download Rational Rhapsody Developer and try it free for 30 days.

• Evaluate IBM software in the way that suits you best: Download it for a trial, tryit online, use it in a cloud environment, or spend a few hours in the SOASandbox learning how to implement service-oriented architecture efficiently.

Discuss

• Join the discussion in the Rational Rhapsody forum.

• Share your knowledge and help others who use Rational software by writing adeveloperWorks article. You'll get worldwide exposure, RSS syndication, abyline and a bio, and the benefit of professional editing and production on thedeveloperWorks Rational website. Find out what makes a gooddeveloperWorks article and how to proceed. Start by finding out what makes agood developerWorks Rational article.

• Follow Rational software on Facebook, Twitter (@ibmrational), and YouTube,and add your comments and requests.

• Ask and answer questions and increase your expertise when you get involvedin the Rational forums, cafés, and wikis.

• Connect with others who share your interests by joining the developerWorkscommunity and responding to the developer-driven blogs.

About the author

Beery D. Holstein

ibm.com/developerWorks developerWorks®

Speed delivery of Android devices and applications with model-driven development Trademarks© Copyright IBM Corporation 2011 Page 13 of 14

Page 14: Speed delivery of Android devices and applications with model-driven development

Beery Holstein has more than 20 years experience in developingsoftware engineering tools and over a decade of experience withdeveloping Rhapsody, an MDD tool for the embedded, real-timesoftware development industry. He was one of the first members of theteam that developed Rhapsody, before it became part of IBM Rationalsoftware (i-Logix and then Telelogic). Beery is now managing thedevelopment of the core product, including among other things, thecode generation, reverse engineering, and round-trip capabilities thatunderlie support for Android.

developerWorks® ibm.com/developerWorks

Speed delivery of Android devices and applications with model-driven development Trademarks© Copyright IBM Corporation 2011 Page 14 of 14