SlideShare a Scribd company logo
App Architectures
&
Better Coding Guidelines
Syed Qamar Abbas
Software Engineer – Android
https://www.linkedin.com/in/qamar4p
Email: qamar.dev@gmail.com
Content
• How to code better?
• The most important design patterns
• Anti patterns in software development
• SOLID principles of object-oriented programming by Uncle Bob
• Dependency Injection
• Why should you care about app architecture?
• App architectures MVC, MVP, MVVM
• Android specific libraries for inspiration
• MVVM Android Example
• References
How to code better?
• Write descriptive class, function and variable names
• Consistent name scheme
• Logical grouping (based on screens/ app features/ architecture layers)
• Don’t repeat code
• Make comments, particularly in hard-to-understand areas
• Break down a big task into smaller chunks
• Prefer standard libraries
• Use design patterns
The Most Important Design Patterns
• Creational design patterns
• Singleton
• Abstract Factory
• Builder
• Structural design patterns
• Adapter
• Bridge
• Proxy
• Behavioral design patterns
• Command
• Observer
Anti Patterns
• An AntiPattern is a literary form that describes a commonly occurring
solution to a problem that generates decidedly negative
consequences.
• Software Development AntiPatterns
• Spaghetti Code
• Dead End
• Cut-and-Paste Programming
• Software Architecture AntiPatterns
• Software Project Management AntiPatterns
S.O.L.I.D— the five basic principles of object-oriented programming and design by Uncle Bob
Mobile App Architectures & Coding guidelines
Need of
accountant
in future.
Changes
required
Continued…
Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelines
Mobile App Architectures & Coding guidelines
DI Example
Problem
Solution
Dependency Injection?
• In software engineering, dependency injection is a technique whereby
one object (or static method) supplies the dependencies of another
object. A dependency is an object that can be used (a service).
Example (bad)
Example (Good)
How DI works
Swinject https://github.com/Swinject/Swinject ★ 3,2453
★ 13,554
Dependency Inversion vs Dependency
Injection
• Dependency Injection is an Inversion of Control technique for
supplying objects ('dependencies') to a class by way of the Dependency
Injection Design Pattern. Typically passing dependencies via one of the
following:
• A constructor
• A public property or field
• A public setter
• The Dependency Inversion Principle (DIP) is a software
design guideline which boils down to two recommendations about de-
coupling a class from its concrete dependencies:
• 'High-level modules should not depend on low-level modules. Both should depend on
abstractions.'
• 'Abstractions should not depend upon details. Details should depend upon
abstractions.'
Yes, DI means Dependency Injection
Libraries like dagger2 generated compile time code
Why should you care about app architecture?
• Enables quicker changes in a layer, without impacting others
• Higher adaptability. New technical features
• It allows for different teams to divide work.
• You are able to scale the application up and out.
• It adds reliability and more independence
• Easy maintenance of the code base
• Great testability
• Easy to understand
Application architecture (Continue…)
1. MVC: Model View Controller
2. MVP: Model View Presenter
3. MVVM: Model View ViewModel
4. MVI: Model-View-Intent
5. VIPER: View Interactor Presenter Entity Routing
6. FLUX and REDUX: well, just Redux, although it should be called
ActionCreator-Action-Dispatcher-Middleware-Reducer-Store-
Middleware-View
Application architecture (MVC)
• Model
the data layer, responsible for managing the business logic and handling
network or database API.
• View
the UI layer — a visualisation of the data from the Model.
• Controller
the logic layer, gets notified of the user’s behavior and updates the Model as
needed.
Application architecture (MVC)
• Distribution —the View and
the Model in fact separated,
but the View and
the Controller are tightly
coupled.
• Testability— due to the bad
distribution you’ll probably
only test your Model.
Application architecture (MVP)
• Model
Same as MVC / No change
• View
The only change here is that the Activity/Fragment is now considered
part of the view.
• Presenter
This is essentially the controller from MVC except that it is not at all tied to the
View, just an interface. This addresses the testability concerns as well as the
modularity/flexibility concerns we had with MVC. In fact, MVP purists would
argue that the presenter should never have any references to any Android APIs
or code.
MVP
MVC vs MVP
• MVP
• View is more loosely coupled to the model. The
presenter is responsible for binding the model to
the view.
• Easier to unit test because interaction with the view
is through an interface
• Usually view to presenter map one to one.
• MVC
• Controller are based on behaviors and can be
shared across views
• Can be responsible for determining which view to
display
Application architecture (MVVM)
• Model
Same as MVC / No change
• View
The view binds to observable variables and actions exposed by the viewModel
in a flexible way.
• ViewModel
The ViewModel is responsible for wrapping the model and preparing
observable data needed by the view.
Application architecture (MVVM)
• MVVM treats the view controller/activities/fragments as the View
• There is no tight coupling between the View and the Model
• In addition, it does binding like the Supervising version of the MVP
• Bindings
• Bindings come out of box for the OS X development
• In iOS KVO based SwiftBond binding can be used or ReactiveCocoa, RxSwift
• In Android DataBinding is supported in Studio (new name ViewBinding)
Application architecture (MVVM)
Android specific libraries (latest)
• Jetpack is a suite of libraries, tools, and guidance to help developers
write high-quality apps easier
• Navigation, ViewModel, LiveData, Room etc
• Retrofit, OkHttp
• RXJava2, Kotlin Coroutine
• Dagger2, Koin for Kotlin
• Junit, Expresso, mockito
• Gson, Moshi, Glide, Picasso
MVVM Android Example
• Pre-requisites
• Android Studio and Gradle v3.4.0
• Android SDK 28
• Android Build Tools v28.0.0
• Android Support Repository
• Architecture components
• Dagger2
• Live data
• RX JAVA and ViewModel
• Android architecture component
• Testing
• Mockito
• JUnit
Mobile App Architectures & Coding guidelines
Thank you!
Q&A
References
• https://medium.com/@karthikcsridhar/s-o-l-i-d-principles-in-java-
1aaff453d7ea
• https://proandroiddev.com/mvc-mvp-mvvm-clean-viper-redux-mvi-
prnsaaspfruicc-building-abstractions-for-the-sake-of-building-
18459ab89386
• https://medium.com/ios-os-x-development/ios-architecture-
patterns-ecba4c38de52
• https://www.raywenderlich.com/636803-mvvm-and-databinding-
android-design-patterns

More Related Content

PPTX
Training: MVVM Pattern
Betclic Everest Group Tech Team
 
PPTX
Design Pattern - MVC, MVP and MVVM
Mudasir Qazi
 
PPTX
ASP .NET MVC Introduction & Guidelines
Dev Raj Gautam
 
PDF
MVC Seminar Presantation
Abhishek Yadav
 
PPTX
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
Jinkyu Kim
 
PPTX
Acrhitecture deisign pattern_MVC_MVP_MVVM
Dong-Ho Lee
 
PPTX
MVx patterns in iOS (MVC, MVP, MVVM)
Yaroslav Voloshyn
 
Training: MVVM Pattern
Betclic Everest Group Tech Team
 
Design Pattern - MVC, MVP and MVVM
Mudasir Qazi
 
ASP .NET MVC Introduction & Guidelines
Dev Raj Gautam
 
MVC Seminar Presantation
Abhishek Yadav
 
Software architectural design patterns(MVC, MVP, MVVM, VIPER) for iOS
Jinkyu Kim
 
Acrhitecture deisign pattern_MVC_MVP_MVVM
Dong-Ho Lee
 
MVx patterns in iOS (MVC, MVP, MVVM)
Yaroslav Voloshyn
 

What's hot (20)

ODP
What is MVC?
Dom Cimafranca
 
PPTX
Mvc fundamental
Nguyễn Thành Phát
 
PDF
Understanding iOS from an Android perspective
Lauren Yew
 
PPTX
Ps02 cint24 mvc in php
Conestoga Collage
 
PPTX
Introduction to mvc architecture
ravindraquicsolv
 
PPT
MSDN - ASP.NET MVC
Maarten Balliauw
 
PPT
MVC(Model View Controller),Web,Enterprise,Mobile
naral
 
PPT
MVC ppt presentation
Bhavin Shah
 
PPTX
Feature flag launchdarkly
Sandeep Soni
 
PDF
Infinum Android Talks #12 - MVP design pattern for Android Apps
Infinum
 
PPT
Design pattern in android
Jay Kumarr
 
PPTX
ASP.NET MVC Presentation
Volkan Uzun
 
PPTX
Asp.net mvc presentation by Nitin Sawant
Nitin S
 
PPT
ASP.NET MVC Presentation
ivpol
 
PPT
MVC Architecture in ASP.Net By Nyros Developer
Nyros Technologies
 
PPT
Ppt of Basic MVC Structure
Dipika Wadhvani
 
PPTX
Mvc summary
Muhammad Younis
 
PDF
JavaCro'15 - Web UI best practice integration with Java EE 7 - Peter Lehto
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
PPT
MVC Pattern. Flex implementation of MVC
Anton Krasnoshchok
 
PDF
Model View Controller (MVC)
Javier Antonio Humarán Peñuñuri
 
What is MVC?
Dom Cimafranca
 
Mvc fundamental
Nguyễn Thành Phát
 
Understanding iOS from an Android perspective
Lauren Yew
 
Ps02 cint24 mvc in php
Conestoga Collage
 
Introduction to mvc architecture
ravindraquicsolv
 
MSDN - ASP.NET MVC
Maarten Balliauw
 
MVC(Model View Controller),Web,Enterprise,Mobile
naral
 
MVC ppt presentation
Bhavin Shah
 
Feature flag launchdarkly
Sandeep Soni
 
Infinum Android Talks #12 - MVP design pattern for Android Apps
Infinum
 
Design pattern in android
Jay Kumarr
 
ASP.NET MVC Presentation
Volkan Uzun
 
Asp.net mvc presentation by Nitin Sawant
Nitin S
 
ASP.NET MVC Presentation
ivpol
 
MVC Architecture in ASP.Net By Nyros Developer
Nyros Technologies
 
Ppt of Basic MVC Structure
Dipika Wadhvani
 
Mvc summary
Muhammad Younis
 
JavaCro'15 - Web UI best practice integration with Java EE 7 - Peter Lehto
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
MVC Pattern. Flex implementation of MVC
Anton Krasnoshchok
 
Model View Controller (MVC)
Javier Antonio Humarán Peñuñuri
 
Ad

Similar to Mobile App Architectures & Coding guidelines (20)

PDF
MVP Clean Architecture
Himanshu Dudhat
 
PPTX
Architectural Design & Patterns
Inocentshuja Ahmad
 
PPTX
MVC.pptx
HassanAliKhan36
 
PPTX
MWLUG 2015 - An Introduction to MVC
Ulrich Krause
 
PPTX
An Introduction To Model  View  Controller In XPages
Ulrich Krause
 
PPTX
MVC architecture by Mohd.Awais on 18th Aug, 2017
Innovation Studio
 
PPTX
MVC Framework
Ashton Feller
 
PPTX
Spring Web Presentation 123143242341234234
horiadobrin
 
PPTX
Spring Web Presentation - Framework and Its Ecosystem
horiadobrin
 
PPT
Spring - a framework written by developers
MarcioSoaresPereira1
 
PDF
Models used in iOS programming, with a focus on MVVM
Andrei Popa
 
PPTX
Building databound JavaScript apps with Knockoutjs
Nish Anil
 
PDF
Action-Domain-Responder: A Web-Specific Refinement of Model-View-Controller
Paul Jones
 
PPTX
Introduction to Spring Framework
ASG
 
PPTX
Mcv design patterns
Rob Paok
 
PDF
Asp.NETZERO - A Workshop Presentation by Citytech Software
Ritwik Das
 
PPTX
Mvc pattern and implementation in java fair
Tech_MX
 
PPTX
MVVM for Modern Applications
Jeremy Likness
 
PPTX
Adopting MVVM
John Cumming
 
MVP Clean Architecture
Himanshu Dudhat
 
Architectural Design & Patterns
Inocentshuja Ahmad
 
MVC.pptx
HassanAliKhan36
 
MWLUG 2015 - An Introduction to MVC
Ulrich Krause
 
An Introduction To Model  View  Controller In XPages
Ulrich Krause
 
MVC architecture by Mohd.Awais on 18th Aug, 2017
Innovation Studio
 
MVC Framework
Ashton Feller
 
Spring Web Presentation 123143242341234234
horiadobrin
 
Spring Web Presentation - Framework and Its Ecosystem
horiadobrin
 
Spring - a framework written by developers
MarcioSoaresPereira1
 
Models used in iOS programming, with a focus on MVVM
Andrei Popa
 
Building databound JavaScript apps with Knockoutjs
Nish Anil
 
Action-Domain-Responder: A Web-Specific Refinement of Model-View-Controller
Paul Jones
 
Introduction to Spring Framework
ASG
 
Mcv design patterns
Rob Paok
 
Asp.NETZERO - A Workshop Presentation by Citytech Software
Ritwik Das
 
Mvc pattern and implementation in java fair
Tech_MX
 
MVVM for Modern Applications
Jeremy Likness
 
Adopting MVVM
John Cumming
 
Ad

Recently uploaded (20)

PDF
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PDF
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
PPTX
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
PDF
Best ERP System for Manufacturing in India | Elite Mindz
Elite Mindz
 
PDF
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
PPTX
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
PPT
L2 Rules of Netiquette in Empowerment technology
Archibal2
 
PDF
Doc9.....................................
SofiaCollazos
 
PPTX
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PPTX
Stamford - Community User Group Leaders_ Agentblazer Status, AI Sustainabilit...
Amol Dixit
 
PDF
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
PPT
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
 
PDF
REPORT: Heating appliances market in Poland 2024
SPIUG
 
PPTX
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
PDF
Software Development Company | KodekX
KodekX
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
Oracle AI Vector Search- Getting Started and what's new in 2025- AIOUG Yatra ...
Sandesh Rao
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
NewMind AI Weekly Chronicles - July'25 - Week IV
NewMind AI
 
cloud computing vai.pptx for the project
vaibhavdobariyal79
 
Best ERP System for Manufacturing in India | Elite Mindz
Elite Mindz
 
The Evolution of KM Roles (Presented at Knowledge Summit Dublin 2025)
Enterprise Knowledge
 
New ThousandEyes Product Innovations: Cisco Live June 2025
ThousandEyes
 
L2 Rules of Netiquette in Empowerment technology
Archibal2
 
Doc9.....................................
SofiaCollazos
 
ChatGPT's Deck on The Enduring Legacy of Fax Machines
Greg Swan
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
Stamford - Community User Group Leaders_ Agentblazer Status, AI Sustainabilit...
Amol Dixit
 
How-Cloud-Computing-Impacts-Businesses-in-2025-and-Beyond.pdf
Artjoker Software Development Company
 
Coupa-Kickoff-Meeting-Template presentai
annapureddyn
 
REPORT: Heating appliances market in Poland 2024
SPIUG
 
How to Build a Scalable Micro-Investing Platform in 2025 - A Founder’s Guide ...
Third Rock Techkno
 
Automating ArcGIS Content Discovery with FME: A Real World Use Case
Safe Software
 
Software Development Company | KodekX
KodekX
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 

Mobile App Architectures & Coding guidelines

  • 1. App Architectures & Better Coding Guidelines Syed Qamar Abbas Software Engineer – Android https://www.linkedin.com/in/qamar4p Email: [email protected]
  • 2. Content • How to code better? • The most important design patterns • Anti patterns in software development • SOLID principles of object-oriented programming by Uncle Bob • Dependency Injection • Why should you care about app architecture? • App architectures MVC, MVP, MVVM • Android specific libraries for inspiration • MVVM Android Example • References
  • 3. How to code better? • Write descriptive class, function and variable names • Consistent name scheme • Logical grouping (based on screens/ app features/ architecture layers) • Don’t repeat code • Make comments, particularly in hard-to-understand areas • Break down a big task into smaller chunks • Prefer standard libraries • Use design patterns
  • 4. The Most Important Design Patterns • Creational design patterns • Singleton • Abstract Factory • Builder • Structural design patterns • Adapter • Bridge • Proxy • Behavioral design patterns • Command • Observer
  • 5. Anti Patterns • An AntiPattern is a literary form that describes a commonly occurring solution to a problem that generates decidedly negative consequences. • Software Development AntiPatterns • Spaghetti Code • Dead End • Cut-and-Paste Programming • Software Architecture AntiPatterns • Software Project Management AntiPatterns
  • 6. S.O.L.I.D— the five basic principles of object-oriented programming and design by Uncle Bob
  • 14. Dependency Injection? • In software engineering, dependency injection is a technique whereby one object (or static method) supplies the dependencies of another object. A dependency is an object that can be used (a service). Example (bad)
  • 15. Example (Good) How DI works Swinject https://github.com/Swinject/Swinject ★ 3,2453 ★ 13,554
  • 16. Dependency Inversion vs Dependency Injection • Dependency Injection is an Inversion of Control technique for supplying objects ('dependencies') to a class by way of the Dependency Injection Design Pattern. Typically passing dependencies via one of the following: • A constructor • A public property or field • A public setter • The Dependency Inversion Principle (DIP) is a software design guideline which boils down to two recommendations about de- coupling a class from its concrete dependencies: • 'High-level modules should not depend on low-level modules. Both should depend on abstractions.' • 'Abstractions should not depend upon details. Details should depend upon abstractions.'
  • 17. Yes, DI means Dependency Injection Libraries like dagger2 generated compile time code
  • 18. Why should you care about app architecture? • Enables quicker changes in a layer, without impacting others • Higher adaptability. New technical features • It allows for different teams to divide work. • You are able to scale the application up and out. • It adds reliability and more independence • Easy maintenance of the code base • Great testability • Easy to understand
  • 19. Application architecture (Continue…) 1. MVC: Model View Controller 2. MVP: Model View Presenter 3. MVVM: Model View ViewModel 4. MVI: Model-View-Intent 5. VIPER: View Interactor Presenter Entity Routing 6. FLUX and REDUX: well, just Redux, although it should be called ActionCreator-Action-Dispatcher-Middleware-Reducer-Store- Middleware-View
  • 20. Application architecture (MVC) • Model the data layer, responsible for managing the business logic and handling network or database API. • View the UI layer — a visualisation of the data from the Model. • Controller the logic layer, gets notified of the user’s behavior and updates the Model as needed.
  • 21. Application architecture (MVC) • Distribution —the View and the Model in fact separated, but the View and the Controller are tightly coupled. • Testability— due to the bad distribution you’ll probably only test your Model.
  • 22. Application architecture (MVP) • Model Same as MVC / No change • View The only change here is that the Activity/Fragment is now considered part of the view. • Presenter This is essentially the controller from MVC except that it is not at all tied to the View, just an interface. This addresses the testability concerns as well as the modularity/flexibility concerns we had with MVC. In fact, MVP purists would argue that the presenter should never have any references to any Android APIs or code.
  • 23. MVP
  • 24. MVC vs MVP • MVP • View is more loosely coupled to the model. The presenter is responsible for binding the model to the view. • Easier to unit test because interaction with the view is through an interface • Usually view to presenter map one to one. • MVC • Controller are based on behaviors and can be shared across views • Can be responsible for determining which view to display
  • 25. Application architecture (MVVM) • Model Same as MVC / No change • View The view binds to observable variables and actions exposed by the viewModel in a flexible way. • ViewModel The ViewModel is responsible for wrapping the model and preparing observable data needed by the view.
  • 26. Application architecture (MVVM) • MVVM treats the view controller/activities/fragments as the View • There is no tight coupling between the View and the Model • In addition, it does binding like the Supervising version of the MVP • Bindings • Bindings come out of box for the OS X development • In iOS KVO based SwiftBond binding can be used or ReactiveCocoa, RxSwift • In Android DataBinding is supported in Studio (new name ViewBinding)
  • 28. Android specific libraries (latest) • Jetpack is a suite of libraries, tools, and guidance to help developers write high-quality apps easier • Navigation, ViewModel, LiveData, Room etc • Retrofit, OkHttp • RXJava2, Kotlin Coroutine • Dagger2, Koin for Kotlin • Junit, Expresso, mockito • Gson, Moshi, Glide, Picasso
  • 29. MVVM Android Example • Pre-requisites • Android Studio and Gradle v3.4.0 • Android SDK 28 • Android Build Tools v28.0.0 • Android Support Repository • Architecture components • Dagger2 • Live data • RX JAVA and ViewModel • Android architecture component • Testing • Mockito • JUnit
  • 32. References • https://medium.com/@karthikcsridhar/s-o-l-i-d-principles-in-java- 1aaff453d7ea • https://proandroiddev.com/mvc-mvp-mvvm-clean-viper-redux-mvi- prnsaaspfruicc-building-abstractions-for-the-sake-of-building- 18459ab89386 • https://medium.com/ios-os-x-development/ios-architecture- patterns-ecba4c38de52 • https://www.raywenderlich.com/636803-mvvm-and-databinding- android-design-patterns