63
iPhonical and Model-Driven Software Development Heiko Behrens (itemis) backchannel via #iphonical #iphonedevcon09

iPhonical and model-driven software development for the iPhone

Embed Size (px)

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

Page 1: iPhonical and model-driven software development for the iPhone

iPhonicaland Model-Driven Software Development

Heiko Behrens (itemis)

backchannel via #iphonical #iphonedevcon09

Page 2: iPhonical and model-driven software development for the iPhone

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

Page 3: iPhonical and model-driven software development for the iPhone

Typical Situations

in

Software Development

Sketching some

#iphonical #iphonedevcon09

Page 4: iPhonical and model-driven software development for the iPhone

Boring code

Page 5: iPhonical and model-driven software development for the iPhone

Accidental complexity

Page 6: iPhonical and model-driven software development for the iPhone

Wrong level of abstraction

Page 7: iPhonical and model-driven software development for the iPhone

Anatomy of Modern Software

Software artifact

Page 8: iPhonical and model-driven software development for the iPhone

Anatomy of Modern Software

Libraries

Frameworksmanually written code

Page 9: iPhonical and model-driven software development for the iPhone

Anatomy of Modern Software

schematic code (manually written)

Libraries

Frameworks

manually written code

Page 10: iPhonical and model-driven software development for the iPhone

(rote) coding doesn’t cut it!

Page 11: iPhonical and model-driven software development for the iPhone

Our Problems

Can we solve them with code generation?

Page 12: iPhonical and model-driven software development for the iPhone

Yes, we can!

Page 13: iPhonical and model-driven software development for the iPhone

Common Approaches

to

Advoid Redundancy

Talking about

#iphonical #iphonedevcon09

Page 14: iPhonical and model-driven software development for the iPhone

Wizards

Page 15: iPhonical and model-driven software development for the iPhone

Wizards in Practice

Ruby on Rails

Xcode Project Templates

AppLoop

Page 16: iPhonical and model-driven software development for the iPhone

This wizard whips up a

complete and running

legacy application with

just a single click.

Page 17: iPhonical and model-driven software development for the iPhone

Designers

Page 18: iPhonical and model-driven software development for the iPhone

Designers in Practice

Graphical

Designers

Interface

Builder

Core

Data

Page 19: iPhonical and model-driven software development for the iPhone

Interface Builder

is no abstraction

but another approach

to object construction.

Handwritten code is

still needed.

Page 20: iPhonical and model-driven software development for the iPhone

Core Dataproduces code a

developer can work

with but overwrites

handcrafted value.

Page 21: iPhonical and model-driven software development for the iPhone

Model-Driven

Software Development

Introducing

#mdsd#iphonical #iphonedevcon09

Page 22: iPhonical and model-driven software development for the iPhone

Raise the level

of abstraction

where possible

and generate

code wisely.

Page 23: iPhonical and model-driven software development for the iPhone

One cannot

abstract away

everything.

Manual code is

great for all the

special cases and

details.

Page 24: iPhonical and model-driven software development for the iPhone

Use the best of both worlds at the same time.

Page 25: iPhonical and model-driven software development for the iPhone

Core Data

Isn’t

#mdsd?#iphonical #iphonedevcon09

Page 26: iPhonical and model-driven software development for the iPhone

Models Data Schema

Page 27: iPhonical and model-driven software development for the iPhone

Sophisticated Runtime

Page 28: iPhonical and model-driven software development for the iPhone

Demo

Page 29: iPhonical and model-driven software development for the iPhone

iPhonical

So, what’s #

about?#iphonedevcon09

Page 30: iPhonical and model-driven software development for the iPhone

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

Page 31: iPhonical and model-driven software development for the iPhone

Thoughts of an iPhone developer

Page 32: iPhonical and model-driven software development for the iPhone

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?

Page 33: iPhonical and model-driven software development for the iPhone

Objective Resource

or

“iPhone on Rails”

Will now present

#iphonical #iphonedevcon09

Page 34: iPhonical and model-driven software development for the iPhone

Demo

Page 35: iPhonical and model-driven software development for the iPhone

#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

Page 36: iPhonical and model-driven software development for the iPhone

#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

Page 37: iPhonical and model-driven software development for the iPhone

Objective-C #ftl ?#iphonical #iphonedevcon09

Page 38: iPhonical and model-driven software development for the iPhone

Objective-C

Page 39: iPhonical and model-driven software development for the iPhone

Suppose...

Page 40: iPhonical and model-driven software development for the iPhone

You’d want to core an apple...

Page 41: iPhonical and model-driven software development for the iPhone

... for your kids.

Page 42: iPhonical and model-driven software development for the iPhone

Right tool for the job?

Page 43: iPhonical and model-driven software development for the iPhone

Your trusty swiss army knife!

Page 44: iPhonical and model-driven software development for the iPhone

Suppose...

Page 45: iPhonical and model-driven software development for the iPhone

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

Page 46: iPhonical and model-driven software development for the iPhone

... for an apple cake.

Page 47: iPhonical and model-driven software development for the iPhone

Still the best tool for the job?

Page 48: iPhonical and model-driven software development for the iPhone

Better use this one

Page 49: iPhonical and model-driven software development for the iPhone

...and this one

Page 50: iPhonical and model-driven software development for the iPhone

... a DSL is ...

Page 51: iPhonical and model-driven software development for the iPhone

A specific tool

for a specific job

Page 52: iPhonical and model-driven software development for the iPhone

A specific tool

for a specific job

Page 53: iPhonical and model-driven software development for the iPhone

Use DSLs to describe the world

Idea behind #iphonical :

#iphonedevcon09

Page 54: iPhonical and model-driven software development for the iPhone

! ! ! ! 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

Page 55: iPhonical and model-driven software development for the iPhone

Leverage Entity DSL

for

Objective Resource

Page 56: iPhonical and model-driven software development for the iPhone

View / GUI

ViewController

Entity DSL

Rails

Application

Objective Resource

Entities and

Mapping

JSON / HTTP

Page 57: iPhonical and model-driven software development for the iPhone

Demo

Page 58: iPhonical and model-driven software development for the iPhone

Wait...

#

#iphonedevcon09

iPhonical works

with any framework?

Page 59: iPhonical and model-driven software development for the iPhone

Demo of custom templates

Page 60: iPhonical and model-driven software development for the iPhone

iPhonical: Where to get

and its future #

#iphonedevcon09

Page 61: iPhonical and model-driven software development for the iPhone

code

Open source Apache License 2.0

code.google.com/p/iphonical/

Currently 8 participants

Page 62: iPhonical and model-driven software development for the iPhone

! Publications in upcomingEclipse Magazin

! ShowCase about Conferences

! Tighter integration with Xcode

What’s comming up?