Slide 1

Slide 1 text

Mobile Applications Architecture Modern and eternal ways ;) Constantine Mars Team Lead, Senior Developer @ DataArt

Slide 2

Slide 2 text

Software Architecture The Origins

Slide 3

Slide 3 text

#mobarchclub Why Use Architecture? ● 10:1 reading to writing ratio

Slide 4

Slide 4 text

#mobarchclub Why Use Architecture? ● 10:1 reading to writing ratio

Slide 5

Slide 5 text

#mobarchclub Why Use Architecture? ● Isolate complex or frequently changing code

Slide 6

Slide 6 text

#mobarchclub Why Use Architecture? ● Black box complex areas

Slide 7

Slide 7 text

#mobarchclub Why Use Architecture? ● Avoid bugs

Slide 8

Slide 8 text

#mobarchclub Why Not Use Architecture? ● Costs and benefits of scalability

Slide 9

Slide 9 text

#mobarchclub Why Not Use Architecture? ● No architecture for architecture’s sake

Slide 10

Slide 10 text

#mobarchclub Why Not Use Architecture? ● Trade-off between speed and technical debt

Slide 11

Slide 11 text

#mobarchclub Why Not Use Architecture? ● Spectrum of effort

Slide 12

Slide 12 text

Main Principles Of a good architecture

Slide 13

Slide 13 text

#mobarchclub

Slide 14

Slide 14 text

#mobarchclub KISS = Seep It Simple Stupid

Slide 15

Slide 15 text

#mobarchclub DRY = Don’t Repeat Yourself

Slide 16

Slide 16 text

#mobarchclub YAGNI = You Aren’t Going to Need It!

Slide 17

Slide 17 text

#mobarchclub SRP = Single Responsibility Principle

Slide 18

Slide 18 text

#mobarchclub OCP - Open Closed Principle

Slide 19

Slide 19 text

#mobarchclub LSP - Liskov Substitution Principle

Slide 20

Slide 20 text

#mobarchclub ISP - Interface Segregation Principle

Slide 21

Slide 21 text

#mobarchclub DIP - Dependency Inversion Principle

Slide 22

Slide 22 text

#mobarchclub

Slide 23

Slide 23 text

#mobarchclub Clean Architecture image from https://8thlight.com

Slide 24

Slide 24 text

Mobile Applications Architecture Some specifics. Main complexity levels

Slide 25

Slide 25 text

#mobarchclub Android Has “Good Bones” image from https://8thlight.com Components: -Activities -Fragments -Services -Content Providers -Broadcast Receivers

Slide 26

Slide 26 text

#mobarchclub Mobile has it’s Specifics image from https://8thlight.com App-hopping OS may kill app at random time App components lifecycle is not under control Components should not depend on each other Can’t rely on data, stored in components

Slide 27

Slide 27 text

#mobarchclub Android Activity Lifecycle is like this :) image from https://8thlight.com

Slide 28

Slide 28 text

#mobarchclub Common Principles for Mobile -Separation of concerns -Provide solid user experience -Keep UI lean and simple -Keep UI free of app logic -Drive UI from model -Use persistent model -Assign clear responsibilities model classes

Slide 29

Slide 29 text

#mobarchclub Separation of Concerns. Abstract way image from fernandocejas.com

Slide 30

Slide 30 text

#mobarchclub Levels of Complexity of Android App Architecture 1. L1 - Presenter / ViewModel, Layer Separation, Entities 2. Injection 3. Coordinator 4. Reactive Programming (Rx)

Slide 31

Slide 31 text

#mobarchclub Presenter / View Model Move non-UI logic from controller to another class

Slide 32

Slide 32 text

#mobarchclub Layer Separation Move network, database and business logic to separate layers

Slide 33

Slide 33 text

#mobarchclub Entities Separate view from database. Little or no logic for entities

Slide 34

Slide 34 text

#mobarchclub Dependency injection Decouple layers. Pass dependencies to constructor parameters Or use injection framework (JSR-330, Dagger, AndroidAnnotations, Juice, etc.)

Slide 35

Slide 35 text

#mobarchclub Coordinator Move navigation logic out of views

Slide 36

Slide 36 text

#mobarchclub Reactive Programming Automatically propagate changes between layers and use mapping between data in functional style

Slide 37

Slide 37 text

Mobile Architecture Patterns Common patterns. Not only for Android

Slide 38

Slide 38 text

#mobarchclub MVC: Model - View - Controller

Slide 39

Slide 39 text

#mobarchclub MVP: Model - View - Presenter

Slide 40

Slide 40 text

#mobarchclub MVVM: Model - View - ViewModel

Slide 41

Slide 41 text

#mobarchclub VIPER

Slide 42

Slide 42 text

#mobarchclub RIBs

Slide 43

Slide 43 text

#mobarchclub Architecture Components

Slide 44

Slide 44 text

#mobarchclub Architecture Components image from Guide to App Architecture

Slide 45

Slide 45 text

Project Lifecycle. Agile Architecture Things outside app that influence architecture evolution

Slide 46

Slide 46 text

#mobarchclub Minimum Viable Architecture 1. YAGNI = You aren’t going to need it! 2. RT-RJ-RT Use the Right Tool for the Right Job at the Right Time 3. XP - Change incrementally

Slide 47

Slide 47 text

#mobarchclub Minimum Viable Product

Slide 48

Slide 48 text

#mobarchclub Project (Startup) Lifecycle 1. Search Phase (Discovery, Solution Design, etc.) 2. Execution Phase (Project) 3. Scaling Phase

Slide 49

Slide 49 text

#mobarchclub Search Phase 1. “No architecture at all” 2. Find business model and market fit 3. Acquire first customers 4. Prototype - familiar technology, cobble it together 5. Throw it away later - but not now

Slide 50

Slide 50 text

#mobarchclub Execution Phase 1. “Just enough” architecture 2. Meet near-term customer needs, delight customers 3. Rapid learning and imporovement 4. Team productivity 5. Monolithic architecture 6. Minimal infrastructure 7. NOT about scaling

Slide 51

Slide 51 text

#mobarchclub Change drives the world “The best code you can write now is the code you’ll discard in a couple of years” Martin Fowler

Slide 52

Slide 52 text

#mobarchclub Monolithic Architecture ● Presentation - Web (JS), Android, iOS ● Application / Backend - Java, PHP, Ruby ● Database - Firebase, MySQL, Mongo

Slide 53

Slide 53 text

#mobarchclub Scaling Phase ● Scaling the Team ● Scaling the Technology ● Concurrency and Efficiency

Slide 54

Slide 54 text

#mobarchclub Scaling is the result of the change “If you don’t end up regretting your early technology decisions, you probably over-engineered” Randy Shoup

Slide 55

Slide 55 text

#mobarchclub Scaling. “Next-Gen” Architecture ● Scaling the Technology. Migrations, Concurrency, Other languages ● Scalable persistence. Break-up monolithic DB, split to functional modules ● Identify and eliminate bottlenecks. Increase performance ● Re-Design interfaces

Slide 56

Slide 56 text

Read Learn and expand

Slide 57

Slide 57 text

#mobarchclub Read About Software Architecture Clean Architecture https://8thlight.com/blog/uncle-bob/2012/08/13/the-clean-architecture.html Architecture, the Lost Years by Uncle Bob https://youtu.be/WpkDN78P884 Fernando Cejas - Architecturing Android, Evolution https://fernandocejas.com/2015/07/18/architecting-android-the-evolution/ Minimum Viable Architecture https://www.slideshare.net/RandyShoup/minimum-viable-architecture-good-e nough-is-good-enough-in-a-startup Mobile Architecture Club

Slide 58

Slide 58 text

#mobarchclub Read About Architectural Frameworks Moxy https://github.com/Arello-Mobile/Moxy Mosby https://github.com/sockeqwe/mosby Android MVP Helper https://github.com/Ufkoku/AndroidMVPHelper Clean Architecture https://github.com/android10/Android-CleanArchitecture Reark https://github.com/reark/reark MVP + Dagger2 + Rx https://android.jlelse.eu/mvp-dagger-2-rx-clean-modern-android-app-code- 74f63c9a6f2f Uber RIBs https://github.com/uber/RIBs

Slide 59

Slide 59 text

#mobarchclub Read About Architecture Components Guide to App Architecture https://developer.android.com/topic/libraries/architecture/guide.html Architecture Components https://developer.android.com/topic/libraries/architecture/index.html I/O ‘17 Architecture Components Introduction - https://youtu.be/FrteWKKVyzI Solving the Lifecycle Problem - https://youtu.be/bEKNi1JOrNs Persistence and Offline - https://youtu.be/MfHsPGQ6bgE Architecture Components on GDD Europe - https://youtu.be/Ts-uxYiBEQ8 GDD Europe CodeLabs g.co/codelabs/gdd17 Google Github samples https://github.com/googlesamples/android-architecture-components

Slide 60

Slide 60 text

@ConstantineMars @DataArt Thank you! :) Mobile Architecture Club