SlideShare a Scribd company logo
1 of 18
Scala DSL for Mobile Application
Specification
Specification Language
“A specification language … used during systems analysis, requirement
analysis and system design to describe a system at a much higher level
than a programming language…” -Wikipedia
Spec Languages examples: CASL, VDM, Z, Alloy, UML, etc.
Native Code Generating
Cross-platform translation
Specification
DSL
AST
Android Native
Project
iOS Native
Project
Requirements
Component
Model
Data
structures
Native Code Generating (contd.)
• Requirements – functional and non-functional, use-cases, user-stories,
feature-lists, business rules, etc.
• Component Model – splitting the application area into a set of components
with precise interfaces and behavior:
Widgets
ContentProvider, Entities
Services, BroadcastReceivers
NotificationService
GPS, GMap
Camera, Audio, Sensors
• Data structures – data entities and bindings between entities and
components.
• Specification DSL is a Ubiquitous language of the problem domain.
Domain Specific Language (DSL)
Overview
“Domain modeling (or domain analysis) involves the identification of all
the major components of the domain and how they collaborate.”
– DSLs in Action, D.Ghosh
The problem domain is the processes, entities and business rules that
are part of the analysis.
The solution domain is the implementation of problem domain in
terms of components with precisely defined behavior.
Scala as a host language of a DSL
Scala is a good choice to be a host language of the specification DSL
since it supports a lot of approaches makes it DSL friendly:
• Operators overriding
• Implicit conversions
• Infix notation to avoid parenthesis
• High-order functions, currying
• Meta-programming (macroses)
• Statically typed
Meta Model: Containers and
Components
An application specified in terms of components and connections
between components. Each component could contain inner
components (container).
A connection indicates either data flow or events-handling
relation between components.
GuiContainer is an example of a group of widgets that translates
to UI functionality. A connector between two Gui Containers
means that there is for instance a navigation event from one to
another.
Meta Model: Data Binding and Events
Handling
The DSL supports several kinds of Data Binding relations
between components:
Events-handling allows to add behavior to components, several
groups of events supported (navigation, persistence, messaging,
etc.):
gui1.listView1.onClick >~ gui2.doActivate
gui1.pane1.onUpdate >~ dbPrv.doUpdate
gui1 <~ dbPrv
Read-only binding Write-only binding Bidirectional binding
target <= source source >= target comp1 <=> comp2
Sample App
val mainActivity = GuiContainer(
EditText(‘address), EditText(‘longitude), EditText(‘latitude)
)
val db = DbProvider {
val coordinates = Entity {
val address = Item
val longitude = Item
val latitude = Item
}
}
mainActivity <~> db
mainActivity <=> db.coordinates
Sample App-2
Component Open API
Simplified API that each component conforms to:
trait Component {
val owner: Component
def inners: Set[Component]
def events: Set[Event]
def handlers: Set[Handler]
def bound: Option[Component]
def +=(comp: Component): this.type
def <~(comp: Component): this.type
def ~>(comp: Component): this.type
def <~>(comp: Component): this.type
def <=(comp: Component): this.type
def >=(comp: Component): this.type
def <=>(comp: Component): this.type
def generate(code: Code): Unit
}
Component Open API (contd.)
It’s a component’s responsibility to initialize owner field of each
inner component. events and handlers returns respective lists of
instances and bound reflects a data binding relation added.
+=-operator appends inner components, <~, >~, <~> manage
even-handling capabilities and <=, >=, <=> control data bindings.
Overridden method generate provides native code generating –
business-logic specifics, features implementation using dynamic
template engine.
Component-based Open API (contd.)
Embedding of business logic and customization of the component’s behavior should be applied per each particular component type:
generate(app: Code): Unit = this match {
case root: App =>
root.generate(app)
root.inners.foreach(_.generate(app))
~app
case gui: GuiContainer =>
val activity = Public::Class(gui.id, AndroidAppActivity)
gui.generate(activity)
gui.inners.foreach(_.generate(activity))
case dbPrv: ContentProvider =>
val provider = Public::Class(dbPrv.id, AndroidContentContentProvider)
dbPrv.generate(provider)
dbPrv.inners.foreach(_.generate(provider))
}
Java CodeGen DSL
Code Generation DSL (Codegen DSL or just Codegen) is a meta-programming framework that allows generating
of Java-classes based on dynamic composition of fragments of code into methods and classes.
Fragments of code are templates contain expressions within ${} that calculated while using Scala string
interpolation process. Code fragment trait has a ~-operator that evaluates a template. E.g. fragment
~$"""
super.onCreate(savedInstanceState);
setContentView(R.layout.${activity.sName});
"""
will generate Java-code (activity.sName is “activity1”):
super.onCreate(savedInstanceState);
setContentView(R.layout.activity1);
Java CodeGen DSL (contd.)
Available at https://github.com/alex-evseenko/codegen
Supports API to dynamically add templates and then generate code:
val activity = Public::Class(app.guiPackage, 'MyActivity, AndroidAppActivity)
val onCreate =
Override::Public::Method('onCreate, 'savedInstanceState->AndroidOsBundle, JavaVoid)(
$"""
super.onCreate(savedInstanceState);
setContentView(R.layout.${activity.sName});
""")
activity += onCreate
~activity
Web-platform
To expose the DSL functionality to end-users simple web-app is
available at http://adaldev.com
It consists from Apps Repository, Builder and Target project page to
create an app, translate it to native Android project and then build
binary module.
Advantages and Disadvantages
Clearly defined borders of components
Extendable and customizable components
Automation Integral Testing
Produce readable native code
Cross-platform and multi-versioning
Meta-programming is difficult to integrate with IDE
Supporting of business logic
Reverse engineering from native code to meta-model is difficult
Questions

More Related Content

Similar to Specification Scala DSL for Mobile Application

Современная архитектура Android-приложений - Archetype / Степан Гончаров (90 ...
Современная архитектура Android-приложений - Archetype / Степан Гончаров (90 ...Современная архитектура Android-приложений - Archetype / Степан Гончаров (90 ...
Современная архитектура Android-приложений - Archetype / Степан Гончаров (90 ...Ontico
 
Crafted Design - LJC World Tour Mash Up 2014
Crafted Design - LJC World Tour Mash Up 2014Crafted Design - LJC World Tour Mash Up 2014
Crafted Design - LJC World Tour Mash Up 2014Sandro Mancuso
 
Crafted Design - Sandro Mancuso
Crafted Design - Sandro MancusoCrafted Design - Sandro Mancuso
Crafted Design - Sandro MancusoJAXLondon2014
 
Intro To Android App Development
Intro To Android App DevelopmentIntro To Android App Development
Intro To Android App DevelopmentMike Kvintus
 
Technology and Android.pptx
Technology and Android.pptxTechnology and Android.pptx
Technology and Android.pptxmuthulakshmi cse
 
Overview of atg framework
Overview of atg frameworkOverview of atg framework
Overview of atg frameworkYousuf Roushan
 
Crafted Design - ITAKE 2014
Crafted Design - ITAKE 2014Crafted Design - ITAKE 2014
Crafted Design - ITAKE 2014Sandro Mancuso
 
Android Development
Android DevelopmentAndroid Development
Android Developmentmclougm4
 
Android Introduction
Android IntroductionAndroid Introduction
Android Introductionaswapnal
 
Azure Functions.pptx
Azure Functions.pptxAzure Functions.pptx
Azure Functions.pptxYachikaKamra
 
Framework engineering JCO 2011
Framework engineering JCO 2011Framework engineering JCO 2011
Framework engineering JCO 2011YoungSu Son
 
Android- Introduction for Beginners
Android- Introduction for BeginnersAndroid- Introduction for Beginners
Android- Introduction for BeginnersTripti Tiwari
 
Lecture 05. UI programming for Mobile Apps
Lecture 05. UI programming for Mobile AppsLecture 05. UI programming for Mobile Apps
Lecture 05. UI programming for Mobile AppsMaksym Davydov
 
MyMobileWeb Certification Part II
MyMobileWeb Certification Part IIMyMobileWeb Certification Part II
MyMobileWeb Certification Part IIcrdlc
 

Similar to Specification Scala DSL for Mobile Application (20)

Современная архитектура Android-приложений - Archetype / Степан Гончаров (90 ...
Современная архитектура Android-приложений - Archetype / Степан Гончаров (90 ...Современная архитектура Android-приложений - Archetype / Степан Гончаров (90 ...
Современная архитектура Android-приложений - Archetype / Степан Гончаров (90 ...
 
PPT Companion to Android
PPT Companion to AndroidPPT Companion to Android
PPT Companion to Android
 
Crafted Design - LJC World Tour Mash Up 2014
Crafted Design - LJC World Tour Mash Up 2014Crafted Design - LJC World Tour Mash Up 2014
Crafted Design - LJC World Tour Mash Up 2014
 
Crafted Design - Sandro Mancuso
Crafted Design - Sandro MancusoCrafted Design - Sandro Mancuso
Crafted Design - Sandro Mancuso
 
Intro To Android App Development
Intro To Android App DevelopmentIntro To Android App Development
Intro To Android App Development
 
Technology and Android.pptx
Technology and Android.pptxTechnology and Android.pptx
Technology and Android.pptx
 
Android Anatomy
Android  AnatomyAndroid  Anatomy
Android Anatomy
 
Overview of atg framework
Overview of atg frameworkOverview of atg framework
Overview of atg framework
 
Android Deep Dive
Android Deep DiveAndroid Deep Dive
Android Deep Dive
 
Crafted Design - ITAKE 2014
Crafted Design - ITAKE 2014Crafted Design - ITAKE 2014
Crafted Design - ITAKE 2014
 
Android Technology
Android TechnologyAndroid Technology
Android Technology
 
Android Development
Android DevelopmentAndroid Development
Android Development
 
Android Introduction
Android IntroductionAndroid Introduction
Android Introduction
 
Azure Functions.pptx
Azure Functions.pptxAzure Functions.pptx
Azure Functions.pptx
 
Framework engineering JCO 2011
Framework engineering JCO 2011Framework engineering JCO 2011
Framework engineering JCO 2011
 
Android- Introduction for Beginners
Android- Introduction for BeginnersAndroid- Introduction for Beginners
Android- Introduction for Beginners
 
Angular2 and You
Angular2 and YouAngular2 and You
Angular2 and You
 
Android primer
Android primerAndroid primer
Android primer
 
Lecture 05. UI programming for Mobile Apps
Lecture 05. UI programming for Mobile AppsLecture 05. UI programming for Mobile Apps
Lecture 05. UI programming for Mobile Apps
 
MyMobileWeb Certification Part II
MyMobileWeb Certification Part IIMyMobileWeb Certification Part II
MyMobileWeb Certification Part II
 

Recently uploaded

Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Velvetech LLC
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 

Recently uploaded (20)

Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...Software Project Health Check: Best Practices and Techniques for Your Product...
Software Project Health Check: Best Practices and Techniques for Your Product...
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 

Specification Scala DSL for Mobile Application

  • 1. Scala DSL for Mobile Application Specification
  • 2. Specification Language “A specification language … used during systems analysis, requirement analysis and system design to describe a system at a much higher level than a programming language…” -Wikipedia Spec Languages examples: CASL, VDM, Z, Alloy, UML, etc.
  • 3. Native Code Generating Cross-platform translation Specification DSL AST Android Native Project iOS Native Project Requirements Component Model Data structures
  • 4. Native Code Generating (contd.) • Requirements – functional and non-functional, use-cases, user-stories, feature-lists, business rules, etc. • Component Model – splitting the application area into a set of components with precise interfaces and behavior: Widgets ContentProvider, Entities Services, BroadcastReceivers NotificationService GPS, GMap Camera, Audio, Sensors • Data structures – data entities and bindings between entities and components. • Specification DSL is a Ubiquitous language of the problem domain.
  • 5. Domain Specific Language (DSL) Overview “Domain modeling (or domain analysis) involves the identification of all the major components of the domain and how they collaborate.” – DSLs in Action, D.Ghosh The problem domain is the processes, entities and business rules that are part of the analysis. The solution domain is the implementation of problem domain in terms of components with precisely defined behavior.
  • 6. Scala as a host language of a DSL Scala is a good choice to be a host language of the specification DSL since it supports a lot of approaches makes it DSL friendly: • Operators overriding • Implicit conversions • Infix notation to avoid parenthesis • High-order functions, currying • Meta-programming (macroses) • Statically typed
  • 7. Meta Model: Containers and Components An application specified in terms of components and connections between components. Each component could contain inner components (container). A connection indicates either data flow or events-handling relation between components. GuiContainer is an example of a group of widgets that translates to UI functionality. A connector between two Gui Containers means that there is for instance a navigation event from one to another.
  • 8. Meta Model: Data Binding and Events Handling The DSL supports several kinds of Data Binding relations between components: Events-handling allows to add behavior to components, several groups of events supported (navigation, persistence, messaging, etc.): gui1.listView1.onClick >~ gui2.doActivate gui1.pane1.onUpdate >~ dbPrv.doUpdate gui1 <~ dbPrv Read-only binding Write-only binding Bidirectional binding target <= source source >= target comp1 <=> comp2
  • 9. Sample App val mainActivity = GuiContainer( EditText(‘address), EditText(‘longitude), EditText(‘latitude) ) val db = DbProvider { val coordinates = Entity { val address = Item val longitude = Item val latitude = Item } } mainActivity <~> db mainActivity <=> db.coordinates
  • 11. Component Open API Simplified API that each component conforms to: trait Component { val owner: Component def inners: Set[Component] def events: Set[Event] def handlers: Set[Handler] def bound: Option[Component] def +=(comp: Component): this.type def <~(comp: Component): this.type def ~>(comp: Component): this.type def <~>(comp: Component): this.type def <=(comp: Component): this.type def >=(comp: Component): this.type def <=>(comp: Component): this.type def generate(code: Code): Unit }
  • 12. Component Open API (contd.) It’s a component’s responsibility to initialize owner field of each inner component. events and handlers returns respective lists of instances and bound reflects a data binding relation added. +=-operator appends inner components, <~, >~, <~> manage even-handling capabilities and <=, >=, <=> control data bindings. Overridden method generate provides native code generating – business-logic specifics, features implementation using dynamic template engine.
  • 13. Component-based Open API (contd.) Embedding of business logic and customization of the component’s behavior should be applied per each particular component type: generate(app: Code): Unit = this match { case root: App => root.generate(app) root.inners.foreach(_.generate(app)) ~app case gui: GuiContainer => val activity = Public::Class(gui.id, AndroidAppActivity) gui.generate(activity) gui.inners.foreach(_.generate(activity)) case dbPrv: ContentProvider => val provider = Public::Class(dbPrv.id, AndroidContentContentProvider) dbPrv.generate(provider) dbPrv.inners.foreach(_.generate(provider)) }
  • 14. Java CodeGen DSL Code Generation DSL (Codegen DSL or just Codegen) is a meta-programming framework that allows generating of Java-classes based on dynamic composition of fragments of code into methods and classes. Fragments of code are templates contain expressions within ${} that calculated while using Scala string interpolation process. Code fragment trait has a ~-operator that evaluates a template. E.g. fragment ~$""" super.onCreate(savedInstanceState); setContentView(R.layout.${activity.sName}); """ will generate Java-code (activity.sName is “activity1”): super.onCreate(savedInstanceState); setContentView(R.layout.activity1);
  • 15. Java CodeGen DSL (contd.) Available at https://github.com/alex-evseenko/codegen Supports API to dynamically add templates and then generate code: val activity = Public::Class(app.guiPackage, 'MyActivity, AndroidAppActivity) val onCreate = Override::Public::Method('onCreate, 'savedInstanceState->AndroidOsBundle, JavaVoid)( $""" super.onCreate(savedInstanceState); setContentView(R.layout.${activity.sName}); """) activity += onCreate ~activity
  • 16. Web-platform To expose the DSL functionality to end-users simple web-app is available at http://adaldev.com It consists from Apps Repository, Builder and Target project page to create an app, translate it to native Android project and then build binary module.
  • 17. Advantages and Disadvantages Clearly defined borders of components Extendable and customizable components Automation Integral Testing Produce readable native code Cross-platform and multi-versioning Meta-programming is difficult to integrate with IDE Supporting of business logic Reverse engineering from native code to meta-model is difficult