Top Banner
MOBILE APP DEVELOPMENT ARCHITECTURE & DESIGN PATTERNS Powered by
47

Lublin Startup Festival - Mobile Architecture Design Patterns

Jan 23, 2018

Download

Software

Karol Szmaj
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Lublin Startup Festival - Mobile Architecture Design Patterns

MOBILE APP DEVELOPMENT ARCHITECTURE & DESIGN PATTERNS

Powered by

Page 2: Lublin Startup Festival - Mobile Architecture Design Patterns

Powered by

EXPERIENCE

Page 3: Lublin Startup Festival - Mobile Architecture Design Patterns

ABOUT ME

Karol Szmaj

[email protected]

VP, CTO

+48 725 787 006

Powered by

Page 4: Lublin Startup Festival - Mobile Architecture Design Patterns

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

Page 5: Lublin Startup Festival - Mobile Architecture Design Patterns

DESIGN PATTERNS ARE SET OF GUIDELINES NOT RULES

Powered by

Page 6: Lublin Startup Festival - Mobile Architecture Design Patterns

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

Page 7: Lublin Startup Festival - Mobile Architecture Design Patterns

OUT OF THE BOX APPROACHCODE BEHIND

1

Powered by

Page 8: Lublin Startup Festival - Mobile Architecture Design Patterns

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

Page 9: Lublin Startup Festival - Mobile Architecture Design Patterns

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

Page 10: Lublin Startup Festival - Mobile Architecture Design Patterns
Page 11: Lublin Startup Festival - Mobile Architecture Design Patterns

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

Page 12: Lublin Startup Festival - Mobile Architecture Design Patterns

MVVM –MODEL VIEW VIEWMODEL

2

Powered by

Page 13: Lublin Startup Festival - Mobile Architecture Design Patterns

MVVM

Model-View-ViewModel

Powered by

Notifications

Data Binding

Commands

View ViewModel Model

UI Logic

Code Behind

Presentation

LogicBussiness Logic

And Data

Page 14: Lublin Startup Festival - Mobile Architecture Design Patterns

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)

Page 15: Lublin Startup Festival - Mobile Architecture Design Patterns

Lightweight

Developer controls everything

Implements: Command Patern, ViewModelBase, Messenger

Has IoC Container

MVVMLight

MVVM

frameworks

Powered by

Page 16: Lublin Startup Festival - Mobile Architecture Design Patterns

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

Page 17: Lublin Startup Festival - Mobile Architecture Design Patterns

More complex, harder bootstrap

Better support for View Composition

Event aggregator

Conventions, Coroutines

Stable!

CaliburnMicro

MVVM

frameworks

Powered by

Page 18: Lublin Startup Festival - Mobile Architecture Design Patterns

IOC – INVERSION OF CONTROL

3

Powered by

Page 19: Lublin Startup Festival - Mobile Architecture Design Patterns

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

Page 20: Lublin Startup Festival - Mobile Architecture Design Patterns

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?

Page 21: Lublin Startup Festival - Mobile Architecture Design Patterns

IoC

Classic design

Powered by

ClassA ClassB

ClassC

ClassD

creates

Page 22: Lublin Startup Festival - Mobile Architecture Design Patterns

IoC design

Powered by

ClassA ClassB

ClassC

ClassD

requires

Container

Model

Instance of ClassA

GetInstance

Page 23: Lublin Startup Festival - Mobile Architecture Design Patterns
Page 24: Lublin Startup Festival - Mobile Architecture Design Patterns
Page 25: Lublin Startup Festival - Mobile Architecture Design Patterns
Page 26: Lublin Startup Festival - Mobile Architecture Design Patterns
Page 27: Lublin Startup Festival - Mobile Architecture Design Patterns

CQRS

4

Powered by

Page 28: Lublin Startup Festival - Mobile Architecture Design Patterns

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

Page 29: Lublin Startup Festival - Mobile Architecture Design Patterns

CQRS

Powered by

Page 30: Lublin Startup Festival - Mobile Architecture Design Patterns

ALL OF THIS TO PROVIDE SCALABILITY & A CONSISTENT

VIEW OF THE DATA.[WEB]

Powered by

Page 31: Lublin Startup Festival - Mobile Architecture Design Patterns

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

Page 32: Lublin Startup Festival - Mobile Architecture Design Patterns
Page 33: Lublin Startup Festival - Mobile Architecture Design Patterns
Page 34: Lublin Startup Festival - Mobile Architecture Design Patterns
Page 35: Lublin Startup Festival - Mobile Architecture Design Patterns
Page 36: Lublin Startup Festival - Mobile Architecture Design Patterns
Page 37: Lublin Startup Festival - Mobile Architecture Design Patterns
Page 38: Lublin Startup Festival - Mobile Architecture Design Patterns

TOOLS & TIPS

5

Powered by

Page 39: Lublin Startup Festival - Mobile Architecture Design Patterns

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

Page 40: Lublin Startup Festival - Mobile Architecture Design Patterns

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());

Page 41: Lublin Startup Festival - Mobile Architecture Design Patterns

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)

Page 42: Lublin Startup Festival - Mobile Architecture Design Patterns

What do we get?

Tools - Cimbalino

Powered by

Behaviors

Converters

Extension classes

Services

Helpers

Page 43: Lublin Startup Festival - Mobile Architecture Design Patterns

What do we get?

Tools - Resharper

Powered by

Better IntelliSense

Great refactor tool

XAML Support

R# just rocks!

Page 44: Lublin Startup Festival - Mobile Architecture Design Patterns

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

Page 45: Lublin Startup Festival - Mobile Architecture Design Patterns

What do we get?

Tip #2 – Windows 10 XAML

Powered by

Improved XAML performance

x:Bind – faster compiled binding

Adaptive design

.Net Native

Page 46: Lublin Startup Festival - Mobile Architecture Design Patterns

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

Page 47: Lublin Startup Festival - Mobile Architecture Design Patterns

QUESTIONS?

Karol Szmaj

[email protected]

VP, CTO

+48 725 787 006

Powered by