MOBILE APP DEVELOPMENT ARCHITECTURE & DESIGN PATTERNS Powered by
Agenda
Out of the box approach
MVVM
Inversion of Control
Command and Query Responsibility Segregation
Tools & Tips
1
2
3
4
5
6 Questions
Powered by
Can be overkill for very simple application
Requires more time to bootstrap app
architecture
Disadventages
Powered by
Design Pattern Overview
Simplify maintenance
Separation of concerns
Minimize logic needed in UI
Enable testability
Reduce development time
Easy to customize apps
Adventages
Fast app prototyping
No time required for bootstraping application
Simple design: action + handler
Easy access to visual tree
Pros
Powered by
Out of the box approach
Code Behind
Large view classes
Breaks Single Responsibility Pattern
Hard to mantain in future
Poor code readability
UI customization can break logic inside view
Cons
Powered by
Out of the box approach
Code Behind
Creating small MVP of your product if there is an opportunity to refactor
Testing features
Small apps
When you should use it?
Powered by
When you shouldn’t use it?
Creating MVP without time to refactor
Enterprise apps
For apps with long-term support
Out of the box approach
Code Behind
MVVM
Model-View-ViewModel
Powered by
Notifications
Data Binding
Commands
View ViewModel Model
UI Logic
Code Behind
Presentation
LogicBussiness Logic
And Data
Creating long term-support apps
When considering unit testing
When we need better code mantainability
When you should use it?
MVVM
approach
Powered by
When you shouldn’t use it?
For app testing purpose
When we don’t need testable bussines logic
When project is very simple (avoid architecture overengineering)
Lightweight
Developer controls everything
Implements: Command Patern, ViewModelBase, Messenger
Has IoC Container
MVVMLight
MVVM
frameworks
Powered by
WinRT focused
Support C#, C++/CX and HTML/JS
Validation, Conventions, Attached Events, Messenger, Logging
Very modular
Has IoC – Grace Container
StyleMVVM
MVVM
frameworks
Powered by
More complex, harder bootstrap
Better support for View Composition
Event aggregator
Conventions, Coroutines
Stable!
CaliburnMicro
MVVM
frameworks
Powered by
It’s not a library, framework or tool
It’s like a way of thinking, designing code and general guidelines
Dependency Injection is a set of practices that allow to build loosely coupled
applications
DI & IOC
What is it?
Powered by
Small components that are: independent, reusable, interchamgeable
We gain such benefits like: small classes (SRP), easy maintenance,
extensibility and testability
Dependency Injection is a set of practices that allow to build loosely coupled
applications
Powered by
DI & IOC
What is it?
IoC design
Powered by
ClassA ClassB
ClassC
ClassD
requires
Container
Model
Instance of ClassA
GetInstance
Query stands for reading
Commands stands for writing
Command/Query Responsibility Segregation (CQRS) is the idea that you
can use a different model to update information than the model you use to
read information (web experience).
CQRS
What is it?
Powered by
Classes are responsible for doing one particural job
Easy testability, extensibility and readability
Easy to mantain
Can be shared via multiple projects (portable)
Adventages of CQRS in mobile application:
CQRS
Why do we need it?
Powered by
MrAdvice – AOP tool
MethodTimer – decorates method with a timer
NullGuard – useful for Defensive Programming
Visualize – DebuggerDisplay weaver
Fody is a extensible tool for weaving .net assemblies
Tools - Fody
Powered by
Polly is a .NET 3.5 / 4.0 / 4.5 / PCL (Profile 259) library that allows
developers to express transient exception handling policies such as Retry,
Retry Forever, Wait and Retry or Circuit Breaker in a fluent manner.
Tools - Polly
Powered by
await Policy .Handle<SqlException>(ex => ex.Number == 1205) .Or<ArgumentException>(ex => ex.ParamName == "example") .RetryAsync()
.ExecuteAsync(() => DoSomethingAsync());
Cimbalino Toolkit is a set of useful and powerful tools that will help you build
your Windows Platform applications.
Tools - Cimbalino
Powered by
Supports:
Windows Phone Silverlight 8.0+
Windows Phone / Windows Store 8.0 (WinRT)
Universal App Platform (Windows 10)
What do we get?
Tools - Cimbalino
Powered by
Behaviors
Converters
Extension classes
Services
Helpers
What do we get?
Tools - Resharper
Powered by
Better IntelliSense
Great refactor tool
XAML Support
R# just rocks!
Better to:
Tip #1 – Universal Apps 8.1
Powered by
Separate styles and templates using stalellite libraries
Add ViewModels to portable library NOT to shared project
Design your app architecture to support multiple platforms like Xamarin
Design your project to support adapter pattern
Throwing exceptions from layers is not the best way to handle errors
What do we get?
Tip #2 – Windows 10 XAML
Powered by
Improved XAML performance
x:Bind – faster compiled binding
Adaptive design
.Net Native
App design guidelines
Tip #3 – Xamarin
Powered by
Design your code logic to be not dependant on specific platform
Test your code on each platform
Don’t code without thinking about the problem
Design your code to be simply and readable.
Don’t overengineer your app