t architecture pitfalls in android development
TRANSCRIPT
Architecture pitfalls in Android development.(Why building apps is like building houses)
Thomas Krüger
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
Planning matters
● UMLo structure diagrams (i.e. class diagram)o behavior diagrams (i.e. use case diagram)o interaction diagrams (i.e. sequence diagram)
DRY principle
Don't repeat yourself
"every piece of knowledge must have a single, unambiguous, authoritative representation within a system."
Look for anti-pattern
● Spaghetti code● Big ball of mud● Gas fabric● God object● Yo-yo problem● Magic values
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)
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