• Like

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

MDSD for iPhone and Android

  • 1,780 views
Uploaded on

 

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,780
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
34
Comments
0
Likes
2

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Modellgetriebene App-Entwicklung für iPhone und Android Heiko Behrens, itemis Regionalgruppe Hamburg der GI Hamburg 24.09.2010 @HBehrens http://mobile.itemis.de Dienstag, 28. September 2010
  • 2. Modellgetriebene App-Entwicklung für iPhone und Android Dienstag, 28. September 2010
  • 3. Modellgetriebene App-Entwicklung für iPhone und Android Dienstag, 28. September 2010
  • 4. / soft·ware de·vel·op·ment / n. the set of activities that results in software products. ~ may include research, new development, modification, reuse, maintenance, or any other activities that result in software products. Dienstag, 28. September 2010
  • 5. Typical Situations in Software Development Dienstag, 28. September 2010
  • 6. Boring code Dienstag, 28. September 2010
  • 7. Accidental complexity Dienstag, 28. September 2010
  • 8. Wrong level of abstraction Dienstag, 28. September 2010
  • 9. Anatomy of Modern Software manually written code Frameworks schematic code (manually written) Libraries Dienstag, 28. September 2010
  • 10. Dienstag, 28. September 2010
  • 11. package templates; import java.util.*; import java.io.Serializable; import javax.persistence.*; @SuppressWarnings("serial") @Entity public class Customer implements Serializable { private Long id; private String name; private Address address; private Set<Order> orders = new HashSet<Order>(); // No-arg constructor public Customer() { } @Id public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Address getAddress() { return address; } public void setAddress(Address address) { this.address = address; } @OneToMany public Collection<Order> getOrders() { return orders; } public void setOrders(Set<Order> orders) { this.orders = orders; } } Dienstag, 28. September 2010
  • 12. package templates; import java.io.Serializable; import java.util.*; import javax.persistence.*; @SuppressWarnings("serial") @Entity public class Customer implements Serializable { private Long id; private String name; private Address address; private Set<Order> orders = new HashSet<Order>(); // No-arg constructor public Customer() { } @Id public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Address getAddress() { return address; } public void setAddress(Address address) { this.address = address; } @OneToMany public Collection<Order> getOrders() { return orders; } public void setOrders(Set<Order> orders) { this.orders = orders; } } Dienstag, 28. September 2010
  • 13. Common Approaches to Avoid Redundancy Dienstag, 28. September 2010
  • 14. Wizards Dienstag, 28. September 2010
  • 15. This wizard whips up a complete and running legacy application with just a single click. Dienstag, 28. September 2010
  • 16. Designers Dienstag, 28. September 2010
  • 17. Model-Driven Software Development Dienstag, 28. September 2010
  • 18. Raise the level of abstraction where possible and generate code wisely. Dienstag, 28. September 2010
  • 19. One cannot abstract away everything. Manual code is great for all the special cases and details. Dienstag, 28. September 2010
  • 20. Use the best of both worlds at the same time. Dienstag, 28. September 2010
  • 21. Dienstag, 28. September 2010
  • 22. Suppose... Dienstag, 28. September 2010
  • 23. You’d want to core an apple... Dienstag, 28. September 2010
  • 24. ... for your kids. Dienstag, 28. September 2010
  • 25. Dienstag, 28. September 2010 ? Right tool for the job
  • 26. Your trusty swiss army knife! Dienstag, 28. September 2010
  • 27. Suppose... Dienstag, 28. September 2010
  • 28. You’d want to core a few more apples... Dienstag, 28. September 2010
  • 29. ... for an apple cake. Dienstag, 28. September 2010
  • 30. Still the best tool for the job? Dienstag, 28. September 2010
  • 31. Better use this one Dienstag, 28. September 2010
  • 32. ...and this one Dienstag, 28. September 2010
  • 33. ... a DSL is ... Dienstag, 28. September 2010
  • 34. A specific tool for a specific job Dienstag, 28. September 2010
  • 35. A specific tool for a specific job Dienstag, 28. September 2010
  • 36. Use DSLs to describe the world Dienstag, 28. September 2010
  • 37. select name, salary from employees where salary > 2000 order by salary ^[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}$ Dienstag, 28. September 2010
  • 38. applause http://code.google.com/p/applause/ iPhonical http://code.google.com/p/iphonical/ mobl http://mobl-lang.org/ Dienstag, 28. September 2010
  • 39. entity Vortrag { String titel String untertitel String sprecher String beschreibung } Entities & Data Access contentprovider AllVortragItems returns Vortrag[] fetches XML from "http://spreadsheets.google.com/feeds/list/.../public/values" selects "feed.entry" tableview VortragListe(Vortrag[] items) { title= "Vorträge" section { cell Subtitle foreach items as i { text= i.titel details= i.untertitel Views & Actions action= VortragDetailsView( i ) } } } tabbarApplication itemisApp { button { title= "Vorträge" icon= "66-microphone.png" view= VortragListe( AllVortragItems() ) } button { Navigation title= "Referenten" icon= "person.png" view= SprecherListe( AllSprecherItems() ) } } Dienstag, 28. September 2010
  • 40. Why not use a DSL... ... for building DSLs? Dienstag, 28. September 2010
  • 41. http://www.eclipse.org/Xtext/ @xtext Dienstag, 28. September 2010
  • 42. ar Model m m ra G Generator Runtime Superclass Subclass Class LL(*) Parser ECore meta model Editor Dienstag, 28. September 2010
  • 43. Grammar (similar to EBNF) grammar org.xtext.example.Entity with org.eclipse.xtext.common.Terminals generate entity "http://www.xtext.org/example/Entity" Model: (types+=Type)*; Type: TypeDef | Entity; TypeDef: "typedef" name=ID ("mapsto" mappedType=JAVAID)?; JAVAID: name=ID("." ID)*; Entity: "entity" name=ID ("extends" superEntity=[Entity])? "{" (attributes+=Attribute)* "}"; Attribute: type=[Type] (many?="*")? name=ID; Dienstag, 28. September 2010
  • 44. grammar org.xtext.example.Entity with org.eclipse.xtext.common.Terminals Meta model inference generate entity "http://www.xtext.org/example/Entity" entity Model: (types+=Type)*; Model Type: TypeDef | Entity; types TypeDef: * Type "typedef" name=ID name: EString ("mapsto" mappedType=JAVAID)?; superEntity JAVAID: name=ID("." ID)*; TypeDef Entity Entity: mappedType attributes "entity" name=ID Attribute ("extends" superEntity=[Entity])? JAVAID name: EString "{" name: EString many: EBoolean (attributes+=Attribute)* "}"; type Attribute: type=[Type] (many?="*")? name=ID; Dienstag, 28. September 2010
  • 45. Let’s build a DSL for Mobile Apps Dienstag, 28. September 2010
  • 46. Dienstag, 28. September 2010
  • 47. Anatomy of an iPhone app View title Speaker Table view Name Image Table cell Session Title Location Tab bar Entity Tab bar button Data Provider Dienstag, 28. September 2010
  • 48. Mapping concepts tabbarApplication itemisApp { button { Entity title= "Blog" icon= "08-chat.png" Data Provider view= BlogList( Blogposts() ) } Tab bar button { title= "Talks" Tab bar button icon= "66-microphone.png" view= VortragListe( AllVortragItems() ) Table view } View title button { title= "Speakers" Table cell icon= "person.png" view= SprecherListe( AllSprecherItems() ) } } Dienstag, 28. September 2010
  • 49. Mapping concepts entity BlogItem { String title String author Entity String link String description String pubDate Data Provider BlogItem subItem } Tab bar entity Sprecher { String name Tab bar button String beschreibung String email Table view String blog String fotourl View title String vortraege } entity Vortrag { Table cell String titel String untertitel String sprecher String beschreibung String zeit Vortrag fortsetzung } Dienstag, 28. September 2010
  • 50. Mapping concepts contentprovider Blogposts Entity returns BlogItem[] fetches XML from "http://blogs.itemis.de/?showfeed=1" Data Provider selects "rss.channel.item" Tab bar contentprovider AllVortragItems returns Vortrag[] Tab bar button fetches XML from "http://spreadsheets.google.com/feeds/ Table view list/0Au3-oaNYhfPIdEpRQWxpZnJyX2JCNUdtT1Z4M1B4SkE/1/ public/values" View title selects "feed.entry" Table cell Dienstag, 28. September 2010
  • 51. Mapping concepts Entity Data Provider tableview BlogList(BlogItem[] items) { title= "itemis blog" Tab bar section { cell Subtitle foreach items as i { Tab bar button text= i.author details= i.title image= ("http://blogs.itemis.de/wp-content/ Table view themes/itemis-WP-Theme/photos/" urlconform(i.author) ".jpg") View title action= BlogDetails(i) } Table cell } } Dienstag, 28. September 2010
  • 52. Protected regions Debugger Editor Outlets Profiler Cartridges Polymorphism Type safe Produces any Can run standalone kind of text Eclipse-based (ANT / Maven) Dienstag, 28. September 2010
  • 53. Mapping concepts to code tableview SpeakerList( Speaker[] speakers) { title= "Speakers" section { cell Default foreach speakers as speaker { text= speaker.name image= speaker.smallImageURL action= SpeakerDetails (SpeakerById( speaker.speakerId)) } } } Dienstag, 28. September 2010
  • 54. Cell Rendering - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { ! id item = [self.items objectAtIndex: indexPath.row]; ! UITableViewCell *cell = [self cellDefaultForTableView:tableView]; cell.textLabel.text = [item valueForKeyPath:@"name"]; ! NSString *imageURL = [item valueForKeyPath:@"fotourl"]; cell.imageView.image = [self getImage: imageURL withLoadingImage:@"personLoading.png" andErrorImage:@"personUnknown.png"]; return cell; } Dienstag, 28. September 2010
  • 55. Cell Rendering tableview SpeakerList( Speaker[] speakers) - (UITableViewCell *)tableView:(UITableView *)tableView { cellForRowAtIndexPath:(NSIndexPath *)indexPath { title= "Speakers" ! section id item = [self.items objectAtIndex: indexPath.row]; { ! cell Default foreach UITableViewCell *cell = speakers as speaker [self cellDefaultForTableView:tableView]; { text= speaker.name cell.textLabel.text = [item valueForKeyPath:@"name"]; ! image= speaker.smallImageURL NSString *imageURL = [item valueForKeyPath:@"fotourl"]; action= SpeakerDetails cell.imageView.image = [self getImage: imageURL (SpeakerById( withLoadingImage:@"personLoading.png" speaker.speakerId)) andErrorImage:@"personUnknown.png"]; } } return cell; } } Dienstag, 28. September 2010
  • 56. User Interaction tableview SpeakerList( Speaker[] speakers) - (void)tableView:(UITableView *)tableView { didSelectRowAtIndexPath:(NSIndexPath *)indexPath { title= "Speakers" id item = [self.items objectAtIndex: indexPath.row]; section { IPContentProvider *provider = cell Default foreach [IPSimpleContentProvider providerWithContent:item speakers as speaker andProviders:self.contentProvider.providers]; { text= speaker.name SprecherDetailsViewController *controller = [[SprecherDetailsViewController alloc] init]; image= speaker.smallImageURL controller.contentProvider = provider; action= SpeakerDetails (SpeakerById( [self.navigationController pushViewController: speaker.speakerId)) controller animated: TRUE]; } [controller release]; } } } Dienstag, 28. September 2010
  • 57. Template Invocation tableview SpeakerList( «DEFINE viewModule FOR SectionedView» Speaker[] speakers) «FILE filenameModule()» { #import "«filenameHeader()»" title= "Speakers" #import "NSObject+Applause.h" section «EXPAND imports» { cell Default foreach @implementation «className()» speakers as speaker { «EXPAND sectionCount» text= speaker.name «EXPAND sectionTitleHeader» image= speaker.smallImageURL «EXPAND rowCounts» action= SpeakerDetails «EXPAND cellDescriptions» (SpeakerById( «EXPAND cellSelections» speaker.speakerId)) «EXPAND staticData» } @end } «ENDFILE» } «ENDDEFINE» Dienstag, 28. September 2010
  • 58. Demo Dienstag, 28. September 2010
  • 59. twitter @HBehrens blog http://HeikoBehrens.net consulting mobile.itemis.de Xtext/Xpand eclipse.org applause code.google.com/p/applause Dienstag, 28. September 2010