120
Effective Android Programming with ObjectForms Pavel Lahoda, droidcon Berlin 2011 čtvrtek, 24. března 2011

Droidcon 2011: Effective android programming with object forms

Embed Size (px)

DESCRIPTION

Pavel Lahoda, Perpetum DesignMobile application development is one of most dynamically expanding areas, with hundreds of thousands of applications filling virtual shelves of various application stores. There are dozens of new devices every year with new capabilities, and often with different form factors, which makes the UI development across multiple devices quite challenging. Mobile platforms, such as Android, tends to aid there by introducing concepts brought over from the web applications development, where UI elements are declared in markup language and later glued to the (Java) code. This often results in software that is difficult to comprehend, expensive to maintain, next-to-impossible to reuse and most of all : inefficient.ObjectForms provide an alternative approach. It relies on Java language features, such as introspection to completely eliminate many layers that older approaches deemed necessary to boost both efficiency and reliability of the mobile application development. This talk will look at several myths that are tied to "traditional" approach and provide alternatives. Presentation will explain following :- how Java can be as declarative as XML- removing unnecessary hooks will help the productivity- variations are best handled by polymorphism and conditional statements- reusing code is possible with sticking to OO principlesThe talk is quite compact and has several demos and examples of real, working code.

Citation preview

Page 1: Droidcon 2011: Effective android programming with object forms

Effective Android Programming with ObjectForms

Pavel Lahoda, droidcon Berlin 2011čtvrtek, 24. března 2011

Page 2: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 3: Droidcon 2011: Effective android programming with object forms

2010 : year when demand for mobile application development exploded.

čtvrtek, 24. března 2011

Page 4: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 5: Droidcon 2011: Effective android programming with object forms

So many development projectsSo little time

čtvrtek, 24. března 2011

Page 6: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 7: Droidcon 2011: Effective android programming with object forms

Solution ?Be Effective !

čtvrtek, 24. března 2011

Page 8: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 9: Droidcon 2011: Effective android programming with object forms

What effective means ?

čtvrtek, 24. března 2011

Page 10: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 11: Droidcon 2011: Effective android programming with object forms

Make less steps

čtvrtek, 24. března 2011

Page 12: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 13: Droidcon 2011: Effective android programming with object forms

No detours

čtvrtek, 24. března 2011

Page 14: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 15: Droidcon 2011: Effective android programming with object forms

Releasing application is great feeling, but...

čtvrtek, 24. března 2011

Page 16: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 17: Droidcon 2011: Effective android programming with object forms

...think about the entire lifecycle

čtvrtek, 24. března 2011

Page 18: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 19: Droidcon 2011: Effective android programming with object forms

Create no holes

čtvrtek, 24. března 2011

Page 20: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 21: Droidcon 2011: Effective android programming with object forms

Use right tools

čtvrtek, 24. března 2011

Page 22: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 23: Droidcon 2011: Effective android programming with object forms

Java IDE is your best friend

čtvrtek, 24. března 2011

Page 24: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 25: Droidcon 2011: Effective android programming with object forms

“The most powerful tool for detecting and revealing errors is your compiler. No XML files should be used and code should be written in a way that gives the compiler the opportunity of performing this task as good as possible.”

Apache.orgThe principle of string-free coding

čtvrtek, 24. března 2011

Page 26: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 27: Droidcon 2011: Effective android programming with object forms

Encapsulate your components

čtvrtek, 24. března 2011

Page 28: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 29: Droidcon 2011: Effective android programming with object forms

Strings are nasty beasts

čtvrtek, 24. března 2011

Page 30: Droidcon 2011: Effective android programming with object forms

XML Space invaders

čtvrtek, 24. března 2011

Page 31: Droidcon 2011: Effective android programming with object forms

Avoid excessive typingchevron |ˈ sh evrən|nouna line or stripe in the shape of a V or an inverted V, esp. one on the sleeve of a uniform indicating rank or length of service.

ORIGIN late Middle English (in heraldic use): from Old French, based on Latin caper ‘goat’ ; compare with Latin capreoli (diminutive of caper) used to mean ‘pair of rafters.’

chevronitis |ˈ sh evrənitis|nouna a disease characterized by obsessive typing of strange characters on the computer keyboard, such as chevrons.

ORIGIN late 20th century fell in love of typing enormous amounts of chevrons and other strange characters while “programming”, causing a lot of weird injuries to fingers and hands.

-itissuffixforming names of inflammatory diseases : cystitis | hepatitis.• informal used with reference to a tendency or state of mind that is compared to a disease : creditcarditis.ORIGIN from Greek feminine form of adjectives ending in -itēs (combined with nosos ‘disease’ implied).

čtvrtek, 24. března 2011

Page 32: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 33: Droidcon 2011: Effective android programming with object forms

Chevronitis hurts

čtvrtek, 24. března 2011

Page 34: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 35: Droidcon 2011: Effective android programming with object forms

Alternative ? Meet custom ViewGroup

čtvrtek, 24. března 2011

Page 36: Droidcon 2011: Effective android programming with object forms

Empty ViewGroup

čtvrtek, 24. března 2011

Page 37: Droidcon 2011: Effective android programming with object forms

ViewGroup constructedčtvrtek, 24. března 2011

Page 38: Droidcon 2011: Effective android programming with object forms

ViewGroup layout()

čtvrtek, 24. března 2011

Page 39: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 40: Droidcon 2011: Effective android programming with object forms

Not quite working yet...

čtvrtek, 24. března 2011

Page 41: Droidcon 2011: Effective android programming with object forms

ViewGroup onMeasure()čtvrtek, 24. března 2011

Page 42: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 43: Droidcon 2011: Effective android programming with object forms

That’s a lot of Java code !

čtvrtek, 24. března 2011

Page 44: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 45: Droidcon 2011: Effective android programming with object forms

Reflection to the rescue

čtvrtek, 24. března 2011

Page 46: Droidcon 2011: Effective android programming with object forms

Simplified ViewGroup

čtvrtek, 24. března 2011

Page 47: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 48: Droidcon 2011: Effective android programming with object forms

How AVG works

čtvrtek, 24. března 2011

Page 49: Droidcon 2011: Effective android programming with object forms

Inside ViewGroupHelper

čtvrtek, 24. března 2011

Page 50: Droidcon 2011: Effective android programming with object forms

AVG Usage

čtvrtek, 24. března 2011

Page 51: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 52: Droidcon 2011: Effective android programming with object forms

Need more declarative control ?Annotations !

čtvrtek, 24. března 2011

Page 53: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 54: Droidcon 2011: Effective android programming with object forms

Already learned a lot of principles

čtvrtek, 24. března 2011

Page 55: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 56: Droidcon 2011: Effective android programming with object forms

Time to take it to the next level

čtvrtek, 24. března 2011

Page 57: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 58: Droidcon 2011: Effective android programming with object forms

Keep it simple

čtvrtek, 24. března 2011

Page 59: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 60: Droidcon 2011: Effective android programming with object forms

Don’t repeat yourself

čtvrtek, 24. března 2011

Page 61: Droidcon 2011: Effective android programming with object forms

Introducing ObjectForms

www.objectforms.comčtvrtek, 24. března 2011

Page 62: Droidcon 2011: Effective android programming with object forms

Trivial Examplečtvrtek, 24. března 2011

Page 63: Droidcon 2011: Effective android programming with object forms

Trivial Examplečtvrtek, 24. března 2011

Page 64: Droidcon 2011: Effective android programming with object forms

Trivial Examplečtvrtek, 24. března 2011

Page 65: Droidcon 2011: Effective android programming with object forms

Hello Worldčtvrtek, 24. března 2011

Page 66: Droidcon 2011: Effective android programming with object forms

Hello Worldčtvrtek, 24. března 2011

Page 67: Droidcon 2011: Effective android programming with object forms

Hello Worldčtvrtek, 24. března 2011

Page 68: Droidcon 2011: Effective android programming with object forms

Hello Worldčtvrtek, 24. března 2011

Page 69: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 70: Droidcon 2011: Effective android programming with object forms

More declarative

čtvrtek, 24. března 2011

Page 71: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 72: Droidcon 2011: Effective android programming with object forms

Sample application

čtvrtek, 24. března 2011

Page 73: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 74: Droidcon 2011: Effective android programming with object forms

Inside the Sample application

čtvrtek, 24. března 2011

Page 75: Droidcon 2011: Effective android programming with object forms

Both modes for free

čtvrtek, 24. března 2011

Page 76: Droidcon 2011: Effective android programming with object forms

Both modes for free

Auto Portrait mode

čtvrtek, 24. března 2011

Page 77: Droidcon 2011: Effective android programming with object forms

Both modes for free

Auto Portrait mode Auto Landscape mode

čtvrtek, 24. března 2011

Page 78: Droidcon 2011: Effective android programming with object forms

Object Encapsulation Examplečtvrtek, 24. března 2011

Page 79: Droidcon 2011: Effective android programming with object forms

Object Encapsulation Examplečtvrtek, 24. března 2011

Page 80: Droidcon 2011: Effective android programming with object forms

Object Encapsulation Examplečtvrtek, 24. března 2011

Page 81: Droidcon 2011: Effective android programming with object forms

Objects as members within Objectčtvrtek, 24. března 2011

Page 82: Droidcon 2011: Effective android programming with object forms

Objects as members within Objectčtvrtek, 24. března 2011

Page 83: Droidcon 2011: Effective android programming with object forms

Objects as members within Objectčtvrtek, 24. března 2011

Page 84: Droidcon 2011: Effective android programming with object forms

Objects as members within Objectčtvrtek, 24. března 2011

Page 85: Droidcon 2011: Effective android programming with object forms

Objects as members within Objectčtvrtek, 24. března 2011

Page 86: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 87: Droidcon 2011: Effective android programming with object forms

Compare traditional approachvs.

ObjectForms developmentčtvrtek, 24. března 2011

Page 88: Droidcon 2011: Effective android programming with object forms

Traditional development approach

čtvrtek, 24. března 2011

Page 89: Droidcon 2011: Effective android programming with object forms

Traditional development approach

čtvrtek, 24. března 2011

Page 90: Droidcon 2011: Effective android programming with object forms

Traditional development approach

čtvrtek, 24. března 2011

Page 91: Droidcon 2011: Effective android programming with object forms

Traditional development approach

čtvrtek, 24. března 2011

Page 92: Droidcon 2011: Effective android programming with object forms

Traditional development approach

čtvrtek, 24. března 2011

Page 93: Droidcon 2011: Effective android programming with object forms

Traditional development approach

čtvrtek, 24. března 2011

Page 94: Droidcon 2011: Effective android programming with object forms

Traditional development approach

čtvrtek, 24. března 2011

Page 95: Droidcon 2011: Effective android programming with object forms

Traditional development approach

čtvrtek, 24. března 2011

Page 96: Droidcon 2011: Effective android programming with object forms

Traditional development approach

čtvrtek, 24. března 2011

Page 97: Droidcon 2011: Effective android programming with object forms

Traditional development approach

čtvrtek, 24. března 2011

Page 98: Droidcon 2011: Effective android programming with object forms

Traditional development approach

čtvrtek, 24. března 2011

Page 99: Droidcon 2011: Effective android programming with object forms

Traditional development approach

čtvrtek, 24. března 2011

Page 100: Droidcon 2011: Effective android programming with object forms

Traditional development approach

čtvrtek, 24. března 2011

Page 101: Droidcon 2011: Effective android programming with object forms

Traditional development approach

čtvrtek, 24. března 2011

Page 102: Droidcon 2011: Effective android programming with object forms

Traditional development approach

čtvrtek, 24. března 2011

Page 103: Droidcon 2011: Effective android programming with object forms

Traditional development approach

čtvrtek, 24. března 2011

Page 104: Droidcon 2011: Effective android programming with object forms

Traditional development approach

čtvrtek, 24. března 2011

Page 105: Droidcon 2011: Effective android programming with object forms

Traditional development approach

čtvrtek, 24. března 2011

Page 106: Droidcon 2011: Effective android programming with object forms

Development with ObjectForms

čtvrtek, 24. března 2011

Page 107: Droidcon 2011: Effective android programming with object forms

Development with ObjectForms

čtvrtek, 24. března 2011

Page 108: Droidcon 2011: Effective android programming with object forms

Development with ObjectForms

čtvrtek, 24. března 2011

Page 109: Droidcon 2011: Effective android programming with object forms

Development with ObjectForms

čtvrtek, 24. března 2011

Page 110: Droidcon 2011: Effective android programming with object forms

Development with ObjectForms

čtvrtek, 24. března 2011

Page 111: Droidcon 2011: Effective android programming with object forms

Development with ObjectForms

čtvrtek, 24. března 2011

Page 112: Droidcon 2011: Effective android programming with object forms

Development with ObjectForms

čtvrtek, 24. března 2011

Page 113: Droidcon 2011: Effective android programming with object forms

Development with ObjectForms

čtvrtek, 24. března 2011

Page 114: Droidcon 2011: Effective android programming with object forms

ObjectForms Demo App

market://details?id=objectforms.android

čtvrtek, 24. března 2011

Page 115: Droidcon 2011: Effective android programming with object forms

Cross platform (GWT)

čtvrtek, 24. března 2011

Page 116: Droidcon 2011: Effective android programming with object forms

čtvrtek, 24. března 2011

Page 117: Droidcon 2011: Effective android programming with object forms

Don’t be afraid !

čtvrtek, 24. března 2011

Page 118: Droidcon 2011: Effective android programming with object forms

Thank you.

čtvrtek, 24. března 2011

Page 119: Droidcon 2011: Effective android programming with object forms

Questions & answers

@perpetumdesign

#objectforms

[email protected]

čtvrtek, 24. března 2011

Page 120: Droidcon 2011: Effective android programming with object forms

CreditsSome of the images are from Flickr using Creative Commons License, all credit goes to their authors.

Entire presentation can be freely distributed under Creative Commons license as well.Chevron definition taken from Dictionary application by Apple, Inc.

ObjectForms is property of PerpetumDesign.Original idea of Java Bean introspection and UI generation came from BeanView by Will Iverson of CTG

Current GWT version uses wonderful reflection package Gwittir from Robert “kebernet” CooperAll other products and trademarks are property of their respective owners.

No chevrons were destroyed during preparing this presentation.

čtvrtek, 24. března 2011