t architecture pitfalls in android development

33
Architecture pitfalls in Android development. (Why building apps is like building houses) Thomas Krüger

Upload: thomas-krueger

Post on 07-Aug-2015

117 views

Category:

Technology


1 download

TRANSCRIPT

Architecture pitfalls in Android development.(Why building apps is like building houses)

Thomas Krüger

Overview

● Explanation● Principles● Planning matters● Pitfalls

● 2008: Mobile developer

● 2010: Freelancer

● Oracle certified Java Programmer

Who's speaking?

Foreword

● no golden way● use whatever suits you best● development "style" has to match● "architecture" can be short-dated

"I don't have a solutionbut I admire the problem"

Explanation

● Expose the structure● hide the implementation details● Realize all of the use cases and scenarios

Part of what you should have an eye on:● Activities● Services● BroadcastReceiver● Content Provider● Intents (implicit/explicit)

...and Lifecycles

Building materials

Lifecycles

Proof of concept

● Possibilitycheck● "Spike"(SCRUM)

o no result = alternative needed?

KISS principle

● keep it simple & stupid!● Simple 2D Game● Unity?● Own OpenGL Engine?● AndEngine?

Planning matters

● UMLo structure diagrams (i.e. class diagram)o behavior diagrams (i.e. use case diagram)o interaction diagrams (i.e. sequence diagram)

"A bad foundationmay cause a bad architecture"

1st: Plan it!2nd: Implement it!

...or else...

Size of architecture

"How big gets your project?"

Size of architecture

DRY principle

Don't repeat yourself

"every piece of knowledge must have a single, unambiguous, authoritative representation within a system."

Second System Syndrome

"I've always done it this way"

Look for anti-pattern

● Spaghetti code● Big ball of mud● Gas fabric● God object● Yo-yo problem● Magic values

Pitfalls

Device fragmentation

UI Threading

● use (multi-) threading wisely● use advantage of AsyncTask● don't leak the context

o context as static member = Bad idea!o at least context as compositiono "getApplicationContext()" may be handy

Android's UI

● Don't create UI like in Java (Swing)

● use XML where possibleo use LayoutInflatero reusabilityo divide UI and logico clear MVP

Orientation lock

Good● Don't worry about rotation (>lifecycle)

Bad● usablity on some devices● no distinct layouts (land/port)

When it's already too late...

Rethink

Redesign

Refactor

Release...?

Refurbish

Facade pattern

Facade pattern

Conclusion

● don't ignore the principles● determine the right size● plan your architecture● rely on best practices● dont fear to refactor● look for pattern● watch out for pitfalls

find me onavailable @

Thank you!