iPhonical and model-driven software development for the iPhone

Preview:

DESCRIPTION

These are the slides of my talk "iPhonical and model-driven software development on the iPhone" at the German iPhone Developer Conference 2009 in Cologne. Unfortunately, this version does not include the 25+ minutes demos I presented during the talk.

Citation preview

iPhonicaland Model-Driven Software Development

Heiko Behrens (itemis)

backchannel via #iphonical #iphonedevcon09

/ 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.

Typical Situations

in

Software Development

Sketching some

#iphonical #iphonedevcon09

Boring code

Accidental complexity

Wrong level of abstraction

Anatomy of Modern Software

Software artifact

Anatomy of Modern Software

Libraries

Frameworksmanually written code

Anatomy of Modern Software

schematic code (manually written)

Libraries

Frameworks

manually written code

(rote) coding doesn’t cut it!

Our Problems

Can we solve them with code generation?

Yes, we can!

Common Approaches

to

Advoid Redundancy

Talking about

#iphonical #iphonedevcon09

Wizards

Wizards in Practice

Ruby on Rails

Xcode Project Templates

AppLoop

This wizard whips up a

complete and running

legacy application with

just a single click.

Designers

Designers in Practice

Graphical

Designers

Interface

Builder

Core

Data

Interface Builder

is no abstraction

but another approach

to object construction.

Handwritten code is

still needed.

Core Dataproduces code a

developer can work

with but overwrites

handcrafted value.

Model-Driven

Software Development

Introducing

#mdsd#iphonical #iphonedevcon09

Raise the level

of abstraction

where possible

and generate

code wisely.

One cannot

abstract away

everything.

Manual code is

great for all the

special cases and

details.

Use the best of both worlds at the same time.

Core Data

Isn’t

#mdsd?#iphonical #iphonedevcon09

Models Data Schema

Sophisticated Runtime

Demo

iPhonical

So, what’s #

about?#iphonedevcon09

View / GUI

ViewController

ServiceFacades

ORM / DAO

Entities Messages

RemoteClient

ServerFacade

Server

Entities

Server

Messages

View DSL

Entity DSL

Remote DSL

Service DSL

Sqlite JSON HTTP

Any

RestService

JBoss / RestEasy

NIB

ViewController

Transfomer

Mapper

Thoughts of an iPhone developer

View / GUI

ViewController

ServiceFacades

ORM / DAO

Entities Messages

RemoteClient

ServerFacade

Server

Entities

Server

Messages

View DSL

Entity DSL

Remote DSL

Service DSL

Sqlite JSON HTTP

Any

RestService

JBoss / RestEasy

NIB

ViewController

Transfomer

Mapper

Most likely legacy

Core Data

BetterManually

Framework

What’s this?

Objective Resource

or

“iPhone on Rails”

Will now present

#iphonical #iphonedevcon09

Demo

#import "ObjectiveResource.h"

#import "Dog.h"

@interface Person : NSObject {

! NSString *personId;

! NSDate *updatedAt;

! NSDate *createdAt;

! NSString *name;

}

@property (nonatomic, retain) NSString *personId;

@property (nonatomic, retain) NSDate *updatedAt;

@property (nonatomic, retain) NSDate *createdAt;

@property (nonatomic, retain) NSString *name;

// returns dogs

- (NSArray *) findAllDogs;

- (NSArray *) findAllDogsWithResponse: (NSError * *) aError;

@end

#import "ObjectiveResource.h"

#import "Person.h"

@implementation Person

@synthesize personId;

@synthesize updatedAt;

@synthesize createdAt;

@synthesize name;

// handle pluralization

+ (NSString *) getRemoteCollectionName {

! return @"people";

}

- (NSArray *) findAllDogs {

! return [Dog findRemote:[NSString stringWithFormat:

@"%@/dogs", personId, nil]];

}

- (NSArray *) findAllDogsWithResponse: (NSError * *) aError {

! return [Dog findRemote:[NSString stringWithFormat:

@"%@/dogs", personId, nil] withResponse: aError];

}

- (void) dealloc {

! [personId release];

! [updatedAt release];

! [createdAt release];

! [name release];

! [super dealloc];

}

@end

Entities with Objective Resource

#import "ObjectiveResource.h"

#import "Dog.h"

@interface Person : NSObject {

! NSString *personId;

! NSDate *updatedAt;

! NSDate *createdAt;

! NSString *name;

}

@property (nonatomic, retain) NSString *personId;

@property (nonatomic, retain) NSDate *updatedAt;

@property (nonatomic, retain) NSDate *createdAt;

@property (nonatomic, retain) NSString *name;

// returns dogs

- (NSArray *) findAllDogs;

- (NSArray *) findAllDogsWithResponse: (NSError * *) aError;

@end

#import "ObjectiveResource.h"

#import "Person.h"

@implementation Person

@synthesize personId;

@synthesize updatedAt;

@synthesize createdAt;

@synthesize name;

// handle pluralization

+ (NSString *) getRemoteCollectionName {

! return @"people";

}

- (NSArray *) findAllDogs {

! return [Dog findRemote:[NSString stringWithFormat:

@"%@/dogs", personId, nil]];

}

- (NSArray *) findAllDogsWithResponse: (NSError * *) aError {

! return [Dog findRemote:[NSString stringWithFormat:

@"%@/dogs", personId, nil] withResponse: aError];

}

- (void) dealloc {

! [personId release];

! [updatedAt release];

! [createdAt release];

! [name release];

! [super dealloc];

}

@end

Real Information Content

Objective-C #ftl ?#iphonical #iphonedevcon09

Objective-C

Suppose...

You’d want to core an apple...

... for your kids.

Right tool for the job?

Your trusty swiss army knife!

Suppose...

You’d want to core a few more apples...

... for an apple cake.

Still the best tool for the job?

Better use this one

...and this one

... a DSL is ...

A specific tool

for a specific job

A specific tool

for a specific job

Use DSLs to describe the world

Idea behind #iphonical :

#iphonedevcon09

! ! ! ! viewController Root {

! ! ! ! ! ! ! ! ui Label myLabel;

! ! ! ! ! ! ! ! ui Textfield myTextfield;

! ! ! ! ! ! ! ! action myAction;

! ! ! ! };

! ! ! ! entity Car {

! ! ! ! ! ! ! ! String name;

! ! ! ! ! ! ! ! String number;

! ! ! ! ! ! ! ! Integer km;

! ! ! ! ! ! ! ! JourneyEntry * journeys;

! ! ! ! };

! ! ! !

! ! ! !

! ! ! ! entity JourneyEntry {

! ! ! ! ! ! ! ! Location startLocation;

! ! ! ! ! ! ! ! Location endLocation;

! ! ! ! ! ! ! ! String comment;

! ! ! ! ! ! ! ! Integer startKm;

! ! ! ! ! ! ! ! Integer endKm;

! ! ! ! ! ! ! ! Car car;

! ! ! ! ! ! ! ! Driver driver;

! ! ! ! ! ! ! ! Reason reason;

! ! ! ! };

! ! ! ! entity CarDataResponse {

! ! ! ! ! ! ! ! String creationDate;

! ! ! ! ! ! ! ! Car car;

! ! ! ! ! ! ! ! Location location;

! ! ! ! ! ! ! ! JourneyEntry journey;

! ! ! ! ! ! ! ! Driver driver;

! ! ! ! };

! ! ! ! restService iDriveLogService "/idrivelogservice" {

! ! ! ! ! ! ! ! baseUrl "http://localhost:8080/iDriveLogRESTWebServices";

! ! ! ! ! ! ! ! get data "/data" response:CarDataResponse;

! ! ! ! };

Entities

Services / Messages

UI

Leverage Entity DSL

for

Objective Resource

View / GUI

ViewController

Entity DSL

Rails

Application

Objective Resource

Entities and

Mapping

JSON / HTTP

Demo

Wait...

#

#iphonedevcon09

iPhonical works

with any framework?

Demo of custom templates

iPhonical: Where to get

and its future #

#iphonedevcon09

code

Open source Apache License 2.0

code.google.com/p/iphonical/

Currently 8 participants

! Publications in upcomingEclipse Magazin

! ShowCase about Conferences

! Tighter integration with Xcode

What’s comming up?

Recommended