SlideShare a Scribd company logo
1 of 37
Download to read offline
Building Large Sustainable Apps
Buğra Oral
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
1
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
2
AGENDA
• Problem
• Project Culture
• Structuring a Sustainable Project
• UI Structuring Dilemmas
• GUI Software Architectures
• State of Art
3
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
Problem
4
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
Problem
5
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
Problem
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
6
Within onCreate
Problem
Scaled
Within onCreate Scaled
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
7
Activity as ClickListener
Problem
Scaled
Activity as ClickListener Scaled
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
8
ButterKnife Example
Problem
Scaled
ButterKnife Scaled
9
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
Problem
Mixed
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
10
Problems
• View id’s
• Refactoring
• Confusion
• Inconsistency
• Hand over rate
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
11
Project Culture
• Conventions
• External Dependencies
• Resources
• Names
• Migrations
12
Project Culture
Conventions
• Main tool of communication is the code.
• Code blocks
• Field / Method / Class names
• Tip : Feature Component Based Names i.e: FlippingContactActivity / FlippingContactFragment
• Tip: Android Support Annotations, ex: View.VISIBLE,GONE
• Don’t ignore exceptions and handle errors gracefully
• Don’t use finalizers, no guarantees.
• Don’t duplicate code
• Have sense of maximum line and method length
• Favor equals methods over static objects
• Avoid nested blocks
• Use checkstyle tools to minimize alienation margin
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
13
External Dependencies
• What could be an external dependency?
• Network library – Retrofit, Volley, Picasso, Wasp
• Parceable Generators - Parceabler
• Factory Method generators - IcePick
• View libraries
• ORM’s – Greendao
• Check out android-arsenal.com
• Select your tools and debate so that there will be no place for two dependency doing similar stuff
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
14
RESOURCES
What are the resources?
• Color
• Drawable
• Arrays
• Strings
• Dimensions
• Styles
• Themes
• Layout
• Menu
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
15
RESOURCES
Naming Conventions
Having a resource convention is very important. Resources can will expand drastically depending on how
you structure them. It’s general conception to rely on prefixes.
• Colors: it is better to have the names set by the designer, and reuse them as logically as possible.
Material guidelines will also encourage you to use them this way, i.e; colorPrimary, colorAccent. For
colors with alphas, it is encouraged to use a $colorname_alpha_percent notation.
• Drawables: same as colors, debate with your designer. It’s helpful to come up with a pattern that uses
prefixes as ic_ logo_ bg_ and so on.
• Layouts: Layout naming are very important, because they also effect your way of coding and increase
clarity.
• activity_$activity_java_name
• fragment_$fragment_java_name
• list_item_$what_this_layout_renders
• pager_item_$what_this_layout_renders
• layout_$what_this_layout_renders
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
16
• Layout View Id’s.
• Duplicate layout id’s are the birth marks of a
chaotic project.
• Refactor renaming an id will change every
single layout file as well as Java class.
• Id’s are too generic, we don’t know that it does.
• From Java file we can’t navigate to actual view
without further investigation.
• What happens if there are two views with same
id’s in a view group? What will findViewbyId
return?
• Suggestion is to use a id pattern, such as
$(layoutfilename)_$viewtype_$whatitdoes
• Also now I can see all the views under some
xml file just by writing R.id.$(layout_name)_
yaay!
Same goes for String resources.
RESOURCES
Naming Conventions
Back to click listener example
17
RESOURCES
Structuring
Android Themes and Styles has strong parenting relationships. Utilize them to diminish line of code and
increase their usage. It’s very important not to break a style/theme structuring pattern.
• For Themes, always have base theme that does not vary from configuration to configuration.
• For styles, same, maintain a base themes; for all base views, TextView, EditText, Button and so on.
• Don’t break parenting for different activity themes and view styles.
• How to know you did a correct style/theme structure? If you need very little adding and modification while
adding new layouts, that’s when you can assume it works.
When all are done accordance with a scalable logic, which is all your files under /res follow a certain rule,
there won’t be much a need to create, duplicate and defect.
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
18
RESOURCES
Structuring
19
Application Structure
• Abstractions
• What should I abstract?
• Almost every Android Component. Application, Activity, Fragment, TextView, Button and so one.
• Why? You will or may need application global behavior the first day of development or 6 months later.
• But, be aware of the overhead! Every abstraction brings 500 byte of overhead to java classes.
• Force your view to use your styles by default in constructer.
• Package structure;
• From experience, in most cases feature based approach works best for Android.
• We can use public/private/package private modifier as they are intended.
• For large apps, containing multiple features, it is such more easier to navigate and locate classes.
• A developer working on a specific feature does not need to go beyond his scope.
• Keep java packages and their resources aligned i.e;
• Different string resource files for features
• Different style/theme parents for feature sets.
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
20
Architectural Design
• What are the most common Android Architectural designs?
• What are Activities and Fragments from a architectural point of view?
• Some will say they are class that you do everything in them.
• When do I use an Fragment instead of Activity?
• Some will say that they are Presenters from MVP pattern.
• If they are Presenters, what are their responsibilities?
• Is a Fragment simply view which should render given data or a something that has some deciding,
loading, changing data capabilities?
• Or are fragments mini activities capable of maintaining their jobs themselves? If so what do I do with
child fragments?
• Wait child fragments? If a fragment a child, does it have to report to its parent fragment or the
Activity?
• Hey what do I do if I need to use a picker? A whole activity, fragment? How do I return the selected
values?
So the fun and chaos begins…
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
21
Architectural Design
Organized Utilization of Activity and Fragments
• In a Application consisting of a bunch of features, a better way to organize is to think your individual
Activities as features.
• They will most generally do data operations, display fragments, open other activities. So they will become
a descriptor of that feature, containing no UI related elements at all.
• All UI stuff should be in Fragments, so that they can be used both in tablets and phones. By replacing
your Fragment with a new one with better design, we begin to maintain better by plunging out and in a
new peace of Lego.
• To arrange Activity and Fragment communication; general conception is to use activities as callback
interfaces, but to further decouple components, we encourage the use of Event Buses.
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
22
Event Bus
Side Explanation
• Event bus is a way of communication between objects. An object subscripts to the bus for certain events.
When the certain event is fired, all that are registered will be notified.
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
23
Architectural Design
Tip
• It is highly encouraged to escape android components and move to plain old java objects. Clean all
codes you can and move to an external java module so that you can run simple unit tests and export your
business logic.
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
24
Architectural Design
Exploring Design Patterns
• What is the general problem we need to attack at? %99 Android projects are
• Hard to test code
• Hard to read code
• Hard to refactor code
• Hard to reuse code
• Hard to handle-config changes code
• Hard to replicate edge-cases code
• Hard to hand-over code
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
25
Architectural Design
Exploring Design Patterns
• Why is it this then?
• ~99% of the Android examples are written this way
• It mostly works
• Framework classes and libraries work this way.
• People have got used to hearing that Android works this way and accepted it.
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
26
Architectural Design
MVC
MVC (Model-View-Controller) : The term MVC is in my opinion highly subjective and highly abstract.
The pain point seems to be around the definition of Controller. There are genuinely two different
interpretations of MVC.
• (less-often) An over-arching term, which is a superset of all MV* architectures that separate some View
from some Model and other middle-ish layer than may or may not communicated with the View & Model
components directly.
• (more-often) A slightly more concrete notion of a pattern that relates the M V and C components in a
triangular relationship which does not allow the user to interact with the View directly but only via a View
and / or Controller. View displays the Model and Model is manipulated via the Controller.
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
27
Architectural Design
MVP
MVP (Model-View-Presenter) : MVP is still to general to understand. Main thing is there is linear
relationship between M V and P components.
• Generally Model is accepted as the source of data and View is acknowledge as a rendering component.
• Responsibilities of Presenter on the other hand differ from interpretation to interpretation.
• one hand there is the case where all view logic is left in the view and the presenter doesn’t get
involved in deciding how to render the model.
• you can also move all the way to having the presenter do all the manipulation of the widgets
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
28
Architectural Design
MVVM
MVVM (Model-View-ViewModel) : This is a popular one in the Microsoft (& Xamarin) world. The thing
that all MVVM architectures have in common is…data-binding!
In a nutshell the ViewModel can define the binding between Views and data properties and if bound two
ways then changes to the view update the model and changes to the model update the view, pretty much for
free.
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
29
Architectural Design
MVA
MVA (Model-View-Adapter) : This one is interesting as its pretty simple. This is like a linear MVC (the
same as MVP above), meaning that there is no communication between the View and the Model.
From what I can deduct, this seems to be very similar to MVP, except for the fact that Adapter can not
store view state, while the presenter could.
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
30
State of Art
Design Patterns
MVP PASSIVE VIEW
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
31
State of Art
MVP Passive View Implementation
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
32
State of Art
MVP Passive View Implementation
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
33
State of Art
MVP Passive View Implementation
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
34
State of Art
MVP Passive View Implementation
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
35
State of Art
MVP Passive View Implementation
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
36
Conclusion
What did we gain?
• We have project that maintains a culture
• We have logically structured resources
• We can have objects independent from lifecycle methods
• All presenters can be exported and used with other layouts
• All view’s behavior can be changed by its presenter
• Modularity boost by moving presenters and view interfaces to a library.
• Presenters are JUnit testable
• View objects can be mocked via classes that implements the view interfaces
• Cool stuff like RxJava and Dagger could be leveraged in the presenters, in the business logic where their
benefit boosts up.
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
Q&A
BUĞRAORAL
© 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
37

More Related Content

Similar to Building Large Sustainable Apps

Choosing a JVM Web Framework
Choosing a JVM Web FrameworkChoosing a JVM Web Framework
Choosing a JVM Web FrameworkMatt Raible
 
Agile Software Development
Agile Software DevelopmentAgile Software Development
Agile Software DevelopmentAhmet Bulut
 
Building resuable and customizable Vue components
Building resuable and customizable Vue componentsBuilding resuable and customizable Vue components
Building resuable and customizable Vue componentsFilip Rakowski
 
GGX 2014 Lari Hotari Modular Monoliths with Spring Boot and Grails 3
GGX 2014 Lari Hotari Modular Monoliths with Spring Boot and Grails 3GGX 2014 Lari Hotari Modular Monoliths with Spring Boot and Grails 3
GGX 2014 Lari Hotari Modular Monoliths with Spring Boot and Grails 3Lari Hotari
 
The 360 Developer
The 360 DeveloperThe 360 Developer
The 360 Developerenteritos
 
Cross-Cultural User Experience: What It Is and How to Do It?
Cross-Cultural User Experience: What It Is and How to Do It?Cross-Cultural User Experience: What It Is and How to Do It?
Cross-Cultural User Experience: What It Is and How to Do It?Ultan O'Broin
 
Adapt Elearning - NZATD Presentation Auckland
Adapt Elearning - NZATD Presentation AucklandAdapt Elearning - NZATD Presentation Auckland
Adapt Elearning - NZATD Presentation AucklandSteve Rayson
 
Benchmarking Web Application Scanners for YOUR Organization
Benchmarking Web Application Scanners for YOUR OrganizationBenchmarking Web Application Scanners for YOUR Organization
Benchmarking Web Application Scanners for YOUR OrganizationDenim Group
 
Responsive web design with various grids and frameworks comparison
Responsive web design with various grids and frameworks comparisonResponsive web design with various grids and frameworks comparison
Responsive web design with various grids and frameworks comparisonDhrubaJyoti Dey
 
Single sourcing to the max
Single sourcing to the maxSingle sourcing to the max
Single sourcing to the maxNeil Perlin
 
Learning Web Development with Ruby on Rails Launch
Learning Web Development with Ruby on Rails LaunchLearning Web Development with Ruby on Rails Launch
Learning Web Development with Ruby on Rails LaunchThiam Hock Ng
 
Managing Creativity
Managing CreativityManaging Creativity
Managing Creativitykamaelian
 
Devconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developedDevconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developedAlexander Makarov
 
Multi-Device Prototypes
Multi-Device PrototypesMulti-Device Prototypes
Multi-Device PrototypesDoug Gapinski
 
Iterating For Success: A Case Study in Remote Paired Programming, The Evoluti...
Iterating For Success: A Case Study in Remote Paired Programming, The Evoluti...Iterating For Success: A Case Study in Remote Paired Programming, The Evoluti...
Iterating For Success: A Case Study in Remote Paired Programming, The Evoluti...VMware Tanzu
 
Coding for different resolutions
Coding for different resolutionsCoding for different resolutions
Coding for different resolutionsRobin Srivastava
 
Top Tips for Responsive eLearning Design
Top Tips for Responsive eLearning Design Top Tips for Responsive eLearning Design
Top Tips for Responsive eLearning Design Cammy Bean
 

Similar to Building Large Sustainable Apps (20)

Choosing a JVM Web Framework
Choosing a JVM Web FrameworkChoosing a JVM Web Framework
Choosing a JVM Web Framework
 
Agile Software Development
Agile Software DevelopmentAgile Software Development
Agile Software Development
 
Building resuable and customizable Vue components
Building resuable and customizable Vue componentsBuilding resuable and customizable Vue components
Building resuable and customizable Vue components
 
GGX 2014 Lari Hotari Modular Monoliths with Spring Boot and Grails 3
GGX 2014 Lari Hotari Modular Monoliths with Spring Boot and Grails 3GGX 2014 Lari Hotari Modular Monoliths with Spring Boot and Grails 3
GGX 2014 Lari Hotari Modular Monoliths with Spring Boot and Grails 3
 
The 360 Developer
The 360 DeveloperThe 360 Developer
The 360 Developer
 
Cross-Cultural User Experience: What It Is and How to Do It?
Cross-Cultural User Experience: What It Is and How to Do It?Cross-Cultural User Experience: What It Is and How to Do It?
Cross-Cultural User Experience: What It Is and How to Do It?
 
A New Hiring Paradigm
A New Hiring ParadigmA New Hiring Paradigm
A New Hiring Paradigm
 
Adapt Elearning - NZATD Presentation Auckland
Adapt Elearning - NZATD Presentation AucklandAdapt Elearning - NZATD Presentation Auckland
Adapt Elearning - NZATD Presentation Auckland
 
Benchmarking Web Application Scanners for YOUR Organization
Benchmarking Web Application Scanners for YOUR OrganizationBenchmarking Web Application Scanners for YOUR Organization
Benchmarking Web Application Scanners for YOUR Organization
 
Responsive web design with various grids and frameworks comparison
Responsive web design with various grids and frameworks comparisonResponsive web design with various grids and frameworks comparison
Responsive web design with various grids and frameworks comparison
 
Sencha Services
Sencha ServicesSencha Services
Sencha Services
 
Software Design
Software DesignSoftware Design
Software Design
 
Single sourcing to the max
Single sourcing to the maxSingle sourcing to the max
Single sourcing to the max
 
Learning Web Development with Ruby on Rails Launch
Learning Web Development with Ruby on Rails LaunchLearning Web Development with Ruby on Rails Launch
Learning Web Development with Ruby on Rails Launch
 
Managing Creativity
Managing CreativityManaging Creativity
Managing Creativity
 
Devconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developedDevconf 2011 - PHP - How Yii framework is developed
Devconf 2011 - PHP - How Yii framework is developed
 
Multi-Device Prototypes
Multi-Device PrototypesMulti-Device Prototypes
Multi-Device Prototypes
 
Iterating For Success: A Case Study in Remote Paired Programming, The Evoluti...
Iterating For Success: A Case Study in Remote Paired Programming, The Evoluti...Iterating For Success: A Case Study in Remote Paired Programming, The Evoluti...
Iterating For Success: A Case Study in Remote Paired Programming, The Evoluti...
 
Coding for different resolutions
Coding for different resolutionsCoding for different resolutions
Coding for different resolutions
 
Top Tips for Responsive eLearning Design
Top Tips for Responsive eLearning Design Top Tips for Responsive eLearning Design
Top Tips for Responsive eLearning Design
 

Recently uploaded

Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...OnePlan Solutions
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesKrzysztofKkol1
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolsosttopstonverter
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfRTS corp
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsJean Silva
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfmaor17
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...kalichargn70th171
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdfAndrey Devyatkin
 
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxUnderstanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxSasikiranMarri
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdfSteve Caron
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slidesvaideheekore1
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxRTS corp
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 

Recently uploaded (20)

Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
Revolutionizing the Digital Transformation Office - Leveraging OnePlan’s AI a...
 
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilitiesAmazon Bedrock in Action - presentation of the Bedrock's capabilities
Amazon Bedrock in Action - presentation of the Bedrock's capabilities
 
eSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration toolseSoftTools IMAP Backup Software and migration tools
eSoftTools IMAP Backup Software and migration tools
 
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdfEnhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
Enhancing Supply Chain Visibility with Cargo Cloud Solutions.pdf
 
Strategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero resultsStrategies for using alternative queries to mitigate zero results
Strategies for using alternative queries to mitigate zero results
 
Zer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdfZer0con 2024 final share short version.pdf
Zer0con 2024 final share short version.pdf
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
The Ultimate Guide to Performance Testing in Low-Code, No-Code Environments (...
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
2024-04-09 - From Complexity to Clarity - AWS Summit AMS.pdf
 
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptxUnderstanding Plagiarism: Causes, Consequences and Prevention.pptx
Understanding Plagiarism: Causes, Consequences and Prevention.pptx
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
[ CNCF Q1 2024 ] Intro to Continuous Profiling and Grafana Pyroscope.pdf
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
Introduction to Firebase Workshop Slides
Introduction to Firebase Workshop SlidesIntroduction to Firebase Workshop Slides
Introduction to Firebase Workshop Slides
 
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptxThe Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
The Role of IoT and Sensor Technology in Cargo Cloud Solutions.pptx
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 

Building Large Sustainable Apps

  • 1. Building Large Sustainable Apps Buğra Oral © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential. 1
  • 2. © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential. 2 AGENDA • Problem • Project Culture • Structuring a Sustainable Project • UI Structuring Dilemmas • GUI Software Architectures • State of Art
  • 3. 3 © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential. Problem
  • 4. 4 © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential. Problem
  • 5. 5 © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential. Problem
  • 6. © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential. 6 Within onCreate Problem Scaled Within onCreate Scaled
  • 7. © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential. 7 Activity as ClickListener Problem Scaled Activity as ClickListener Scaled
  • 8. © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential. 8 ButterKnife Example Problem Scaled ButterKnife Scaled
  • 9. 9 © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential. Problem Mixed
  • 10. © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential. 10 Problems • View id’s • Refactoring • Confusion • Inconsistency • Hand over rate
  • 11. © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential. 11 Project Culture • Conventions • External Dependencies • Resources • Names • Migrations
  • 12. 12 Project Culture Conventions • Main tool of communication is the code. • Code blocks • Field / Method / Class names • Tip : Feature Component Based Names i.e: FlippingContactActivity / FlippingContactFragment • Tip: Android Support Annotations, ex: View.VISIBLE,GONE • Don’t ignore exceptions and handle errors gracefully • Don’t use finalizers, no guarantees. • Don’t duplicate code • Have sense of maximum line and method length • Favor equals methods over static objects • Avoid nested blocks • Use checkstyle tools to minimize alienation margin © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 13. 13 External Dependencies • What could be an external dependency? • Network library – Retrofit, Volley, Picasso, Wasp • Parceable Generators - Parceabler • Factory Method generators - IcePick • View libraries • ORM’s – Greendao • Check out android-arsenal.com • Select your tools and debate so that there will be no place for two dependency doing similar stuff © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 14. 14 RESOURCES What are the resources? • Color • Drawable • Arrays • Strings • Dimensions • Styles • Themes • Layout • Menu © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 15. 15 RESOURCES Naming Conventions Having a resource convention is very important. Resources can will expand drastically depending on how you structure them. It’s general conception to rely on prefixes. • Colors: it is better to have the names set by the designer, and reuse them as logically as possible. Material guidelines will also encourage you to use them this way, i.e; colorPrimary, colorAccent. For colors with alphas, it is encouraged to use a $colorname_alpha_percent notation. • Drawables: same as colors, debate with your designer. It’s helpful to come up with a pattern that uses prefixes as ic_ logo_ bg_ and so on. • Layouts: Layout naming are very important, because they also effect your way of coding and increase clarity. • activity_$activity_java_name • fragment_$fragment_java_name • list_item_$what_this_layout_renders • pager_item_$what_this_layout_renders • layout_$what_this_layout_renders © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 16. © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential. 16 • Layout View Id’s. • Duplicate layout id’s are the birth marks of a chaotic project. • Refactor renaming an id will change every single layout file as well as Java class. • Id’s are too generic, we don’t know that it does. • From Java file we can’t navigate to actual view without further investigation. • What happens if there are two views with same id’s in a view group? What will findViewbyId return? • Suggestion is to use a id pattern, such as $(layoutfilename)_$viewtype_$whatitdoes • Also now I can see all the views under some xml file just by writing R.id.$(layout_name)_ yaay! Same goes for String resources. RESOURCES Naming Conventions Back to click listener example
  • 17. 17 RESOURCES Structuring Android Themes and Styles has strong parenting relationships. Utilize them to diminish line of code and increase their usage. It’s very important not to break a style/theme structuring pattern. • For Themes, always have base theme that does not vary from configuration to configuration. • For styles, same, maintain a base themes; for all base views, TextView, EditText, Button and so on. • Don’t break parenting for different activity themes and view styles. • How to know you did a correct style/theme structure? If you need very little adding and modification while adding new layouts, that’s when you can assume it works. When all are done accordance with a scalable logic, which is all your files under /res follow a certain rule, there won’t be much a need to create, duplicate and defect. © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 18. © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential. 18 RESOURCES Structuring
  • 19. 19 Application Structure • Abstractions • What should I abstract? • Almost every Android Component. Application, Activity, Fragment, TextView, Button and so one. • Why? You will or may need application global behavior the first day of development or 6 months later. • But, be aware of the overhead! Every abstraction brings 500 byte of overhead to java classes. • Force your view to use your styles by default in constructer. • Package structure; • From experience, in most cases feature based approach works best for Android. • We can use public/private/package private modifier as they are intended. • For large apps, containing multiple features, it is such more easier to navigate and locate classes. • A developer working on a specific feature does not need to go beyond his scope. • Keep java packages and their resources aligned i.e; • Different string resource files for features • Different style/theme parents for feature sets. © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 20. 20 Architectural Design • What are the most common Android Architectural designs? • What are Activities and Fragments from a architectural point of view? • Some will say they are class that you do everything in them. • When do I use an Fragment instead of Activity? • Some will say that they are Presenters from MVP pattern. • If they are Presenters, what are their responsibilities? • Is a Fragment simply view which should render given data or a something that has some deciding, loading, changing data capabilities? • Or are fragments mini activities capable of maintaining their jobs themselves? If so what do I do with child fragments? • Wait child fragments? If a fragment a child, does it have to report to its parent fragment or the Activity? • Hey what do I do if I need to use a picker? A whole activity, fragment? How do I return the selected values? So the fun and chaos begins… © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 21. 21 Architectural Design Organized Utilization of Activity and Fragments • In a Application consisting of a bunch of features, a better way to organize is to think your individual Activities as features. • They will most generally do data operations, display fragments, open other activities. So they will become a descriptor of that feature, containing no UI related elements at all. • All UI stuff should be in Fragments, so that they can be used both in tablets and phones. By replacing your Fragment with a new one with better design, we begin to maintain better by plunging out and in a new peace of Lego. • To arrange Activity and Fragment communication; general conception is to use activities as callback interfaces, but to further decouple components, we encourage the use of Event Buses. © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 22. 22 Event Bus Side Explanation • Event bus is a way of communication between objects. An object subscripts to the bus for certain events. When the certain event is fired, all that are registered will be notified. © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 23. 23 Architectural Design Tip • It is highly encouraged to escape android components and move to plain old java objects. Clean all codes you can and move to an external java module so that you can run simple unit tests and export your business logic. © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 24. 24 Architectural Design Exploring Design Patterns • What is the general problem we need to attack at? %99 Android projects are • Hard to test code • Hard to read code • Hard to refactor code • Hard to reuse code • Hard to handle-config changes code • Hard to replicate edge-cases code • Hard to hand-over code © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 25. 25 Architectural Design Exploring Design Patterns • Why is it this then? • ~99% of the Android examples are written this way • It mostly works • Framework classes and libraries work this way. • People have got used to hearing that Android works this way and accepted it. © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 26. 26 Architectural Design MVC MVC (Model-View-Controller) : The term MVC is in my opinion highly subjective and highly abstract. The pain point seems to be around the definition of Controller. There are genuinely two different interpretations of MVC. • (less-often) An over-arching term, which is a superset of all MV* architectures that separate some View from some Model and other middle-ish layer than may or may not communicated with the View & Model components directly. • (more-often) A slightly more concrete notion of a pattern that relates the M V and C components in a triangular relationship which does not allow the user to interact with the View directly but only via a View and / or Controller. View displays the Model and Model is manipulated via the Controller. © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 27. 27 Architectural Design MVP MVP (Model-View-Presenter) : MVP is still to general to understand. Main thing is there is linear relationship between M V and P components. • Generally Model is accepted as the source of data and View is acknowledge as a rendering component. • Responsibilities of Presenter on the other hand differ from interpretation to interpretation. • one hand there is the case where all view logic is left in the view and the presenter doesn’t get involved in deciding how to render the model. • you can also move all the way to having the presenter do all the manipulation of the widgets © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 28. 28 Architectural Design MVVM MVVM (Model-View-ViewModel) : This is a popular one in the Microsoft (& Xamarin) world. The thing that all MVVM architectures have in common is…data-binding! In a nutshell the ViewModel can define the binding between Views and data properties and if bound two ways then changes to the view update the model and changes to the model update the view, pretty much for free. © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 29. 29 Architectural Design MVA MVA (Model-View-Adapter) : This one is interesting as its pretty simple. This is like a linear MVC (the same as MVP above), meaning that there is no communication between the View and the Model. From what I can deduct, this seems to be very similar to MVP, except for the fact that Adapter can not store view state, while the presenter could. © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 30. 30 State of Art Design Patterns MVP PASSIVE VIEW © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 31. 31 State of Art MVP Passive View Implementation © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 32. 32 State of Art MVP Passive View Implementation © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 33. 33 State of Art MVP Passive View Implementation © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 34. 34 State of Art MVP Passive View Implementation © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 35. 35 State of Art MVP Passive View Implementation © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 36. 36 Conclusion What did we gain? • We have project that maintains a culture • We have logically structured resources • We can have objects independent from lifecycle methods • All presenters can be exported and used with other layouts • All view’s behavior can be changed by its presenter • Modularity boost by moving presenters and view interfaces to a library. • Presenters are JUnit testable • View objects can be mocked via classes that implements the view interfaces • Cool stuff like RxJava and Dagger could be leveraged in the presenters, in the business logic where their benefit boosts up. © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential.
  • 37. Q&A BUĞRAORAL © 2003–2014 Monitise Group Limited. All Rights Reserved. Confidential. 37