SlideShare a Scribd company logo
1 of 21
Download to read offline
Architectural Guidance for
Building Mobile Apps Using
Xamarin Forms
Richard Taylor
Vice President of Engineering
SentryOne
@rightincode – http://www.rightincode.com
Who is Richard Taylor?
Full Stack Software Engineer
Lives in Huntersville, NC
Organizer of CLT Xamarin Developers
Lead Organizer of Modern Devs CLT
http://www.rightincode.com
@rightincode
Vice President of Engineering
Huntersville, NC
http://www.sentryone.com
@sentryone
@rightincode - http://www.rightincode.com
What are elements of a “good” software
architecture?
 Separation of Concerns
 Single Responsibility Principle
 Loose Coupling
 Don’t Repeat Yourself (DRY)
@rightincode - http://www.rightincode.com
How can we achieve a “good” software
architecture?
 Use proven architectural styles
Onion Architecture
 Use proven architectural/design patterns
MVVM (Model-View-ViewModel)
Inversion of Control
Dependency Injection
@rightincode - http://www.rightincode.com
Xamarin.Forms – Folder Structure
@rightincode - http://www.rightincode.com
Visual Studio Solution Explorer
Reference Project:
Tip Calculator
Xamarin.Forms Architectural Guidance –
MVVM
 Design pattern that help facilitate the separation
of the business and presentation logic from an
applications user interface.
 The why..
Separation of Concerns
Support unit testing of the view model/model
independently of the user interface
Easier maintenance
@rightincode - http://www.rightincode.com
Xamarin.Forms Architectural Guidance –
MVVM – cont.
View
 Responsible for the user interface
View Model
 Responsible for implementing of the properties and
commands that the view binds to
 Notifies the view when state changes
 Coordinates all required interactions between the
view and model
@rightincode - http://www.rightincode.com
Xamarin.Forms Architectural Guidance –
MVVM – cont.
Model
 Represents the domain objects (data, business rules,
validation)
@rightincode - http://www.rightincode.com
Xamarin.Forms Architectural Guidance –
MVVM – cont.
Options for implementation
Manual (review reference application)
Frameworks
MvvmCross
MVVM Light
Prism
@rightincode - http://www.rightincode.com
Xamarin.Forms Architectural Guidance –
Dependency Injection
 Enables the decoupling of concrete types from
the code that depends on the types
 With DI, dependencies are provided by
external facilities at runtime
 DI is a form of Inversion of Control
@rightincode - http://www.rightincode.com
Xamarin.Forms Architectural Guidance –
Dependency Injection – cont.
 DI helps improve testability
 DI does not require a container that houses
the mapping between interfaces and their
concrete types but DI containers are common
@rightincode - http://www.rightincode.com
Xamarin.Forms Architectural Guidance -
Validation
 Applications implementing the mvvm design pattern
should perform validation in the view model and/or
model
 ValidatableObject<T> approach…
 Properties of the view model/model that require
validation should be of type ValidatableObject<T> that
has validation rules defined in its Validations property
 Validation is done by calling the Validate method of
the ValidatableObject<T> which executes the
validation rules on its Value property
@rightincode - http://www.rightincode.com
Xamarin.Forms Architectural Guidance –
Validation – cont.
 ValidatableObject<T> approach cont.
 Errors are placed in the Error property of the
ValidatableObject<T>
 The IsValid property of the ValidatableObject<T> is
updated to indicate if the validation succeeded or
failed
 For example, the entry view in Xamarin.Forms can be
bound to the IsValid property and be notified if
entered data is valid after validation and update the
user interface accordingly
@rightincode - http://www.rightincode.com
Xamarin.Forms Architectural Guidance -
Navigation
 Support for navigation is built in and is considered
view-first navigation
 View-first navigation has some weaknesses
 Tight coupling between views
 Difficult to coordinate navigation across views and
view models (i.e. initiating navigation from a view
model)
 Difficult to enforce business rules that impact
navigation
 Unit testing navigation is very difficult
@rightincode - http://www.rightincode.com
Xamarin.Forms Architectural Guidance -
Navigation
 View model-first navigation alternative
 Can be achieved by implementing a custom
navigation service or using one of the MVVM
frameworks
 Placing the navigation logic in the view model
 Decouples views
 Improves testability by allowing easier unit testing of
navigation
 Allows business rules to control navigation
@rightincode - http://www.rightincode.com
Xamarin.Forms Architectural Guidance –
Component Communications
 Typical communications between components
are done using events which is a form of
publish-subscribe communications
 Works but…
Requires tight coupling between components
Results in the extended lifespan of components
until all references are removed
@rightincode - http://www.rightincode.com
Xamarin.Forms Architectural Guidance –
Component Communications
 MessagingCenter Class
 Implements the publish-subscribe pattern
 Allows components to communicate without having a
reference to each other
 Allows components to be independently developed
and tested
 Publishers send messages and subscribers listen for
messages they are interested in
 Internally, the MessagingCenter Class uses weak
references – it does not keep objects alive and allows
them to be garbage collected
@rightincode - http://www.rightincode.com
Xamarin.Forms Architectural Guidance –
Unit Testing
@rightincode - http://www.rightincode.com
Code
Resources
 Repo: (code)
https://github.com/rightincode/TipCalcPro
 Onion Architecture
 http://blog.thedigitalgroup.com/chetanv/2015/07/06/und
erstanding-onion-architecture/
 Inversion of Control
 https://martinfowler.com/articles/injection.html
 Unit Testing
 https://www.toptal.com/qa/how-to-write-testable-code-
and-why-it-matters
 Pluralsight
Building a Pragmatic Unit Test Suite
Writing Highly Maintainable Unit Tests
Advance Unit Testing
@rightincode - http://www.rightincode.com
Resources
 Enterprise Application Patterns using
Xamarin.Forms
 https://docs.microsoft.com/en-us/xamarin/xamarin-
forms/enterprise-application-patterns/
 Xamarin.Forms
 https://docs.microsoft.com/en-
us/xamarin/#pivot=platforms&panel=XamarinForms
@rightincode - http://www.rightincode.com

More Related Content

Similar to Architectural Guidance for Building Mobile Apps Using Xamarin.Forms

MVC Architecture: A Detailed Insight to the Modern Web Applications Developme...
MVC Architecture: A Detailed Insight to the Modern Web Applications Developme...MVC Architecture: A Detailed Insight to the Modern Web Applications Developme...
MVC Architecture: A Detailed Insight to the Modern Web Applications Developme...CrimsonpublishersPRSP
 
e-SUAP - Pubblicazione scientifica per evento Inista 2014 (International Symp...
e-SUAP - Pubblicazione scientifica per evento Inista 2014 (International Symp...e-SUAP - Pubblicazione scientifica per evento Inista 2014 (International Symp...
e-SUAP - Pubblicazione scientifica per evento Inista 2014 (International Symp...Sabino Labarile
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )Ahmed Emad
 
Architecting Microservices in .Net
Architecting Microservices in .NetArchitecting Microservices in .Net
Architecting Microservices in .NetRichard Banks
 
King Tut Architecture
King Tut ArchitectureKing Tut Architecture
King Tut ArchitectureGary Pedretti
 
IRJET- MVC Framework: A Modern Web Application Development Approach and Working
IRJET- MVC Framework: A Modern Web Application Development Approach and WorkingIRJET- MVC Framework: A Modern Web Application Development Approach and Working
IRJET- MVC Framework: A Modern Web Application Development Approach and WorkingIRJET Journal
 
MDA Vs Web Ratio for Non It
MDA Vs Web Ratio for Non ItMDA Vs Web Ratio for Non It
MDA Vs Web Ratio for Non Itanicolay
 
MVVM+MEF in Silvelight - W 2010ebday
MVVM+MEF in Silvelight - W 2010ebdayMVVM+MEF in Silvelight - W 2010ebday
MVVM+MEF in Silvelight - W 2010ebdayRicardo Fiel
 
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...Choosing the Right HTML5 Framework to Build your Mobile Web Application White...
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...RapidValue
 
Smart Client Software Factory 2010
Smart Client Software Factory  2010Smart Client Software Factory  2010
Smart Client Software Factory 2010Tomy Ismail
 
MVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,MobileMVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,Mobilenaral
 
Over view of software artitecture
Over view of software artitectureOver view of software artitecture
Over view of software artitectureABDEL RAHMAN KARIM
 
MVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCMVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCAnton Krasnoshchok
 
deliver:Agile 2019 "Testing Microservices: From Development to Production
deliver:Agile 2019 "Testing Microservices: From Development to Productiondeliver:Agile 2019 "Testing Microservices: From Development to Production
deliver:Agile 2019 "Testing Microservices: From Development to ProductionDaniel Bryant
 
Mvvm in the real world tccc10
Mvvm in the real world   tccc10Mvvm in the real world   tccc10
Mvvm in the real world tccc10Bryan Anderson
 

Similar to Architectural Guidance for Building Mobile Apps Using Xamarin.Forms (20)

MVC Architecture: A Detailed Insight to the Modern Web Applications Developme...
MVC Architecture: A Detailed Insight to the Modern Web Applications Developme...MVC Architecture: A Detailed Insight to the Modern Web Applications Developme...
MVC Architecture: A Detailed Insight to the Modern Web Applications Developme...
 
e-SUAP - Pubblicazione scientifica per evento Inista 2014 (International Symp...
e-SUAP - Pubblicazione scientifica per evento Inista 2014 (International Symp...e-SUAP - Pubblicazione scientifica per evento Inista 2014 (International Symp...
e-SUAP - Pubblicazione scientifica per evento Inista 2014 (International Symp...
 
Training: MVVM Pattern
Training: MVVM PatternTraining: MVVM Pattern
Training: MVVM Pattern
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )
 
Adopting MVVM
Adopting MVVMAdopting MVVM
Adopting MVVM
 
Architecting Microservices in .Net
Architecting Microservices in .NetArchitecting Microservices in .Net
Architecting Microservices in .Net
 
King Tut Architecture
King Tut ArchitectureKing Tut Architecture
King Tut Architecture
 
IRJET- MVC Framework: A Modern Web Application Development Approach and Working
IRJET- MVC Framework: A Modern Web Application Development Approach and WorkingIRJET- MVC Framework: A Modern Web Application Development Approach and Working
IRJET- MVC Framework: A Modern Web Application Development Approach and Working
 
MDA Vs Web Ratio for Non It
MDA Vs Web Ratio for Non ItMDA Vs Web Ratio for Non It
MDA Vs Web Ratio for Non It
 
MVVM+MEF in Silvelight - W 2010ebday
MVVM+MEF in Silvelight - W 2010ebdayMVVM+MEF in Silvelight - W 2010ebday
MVVM+MEF in Silvelight - W 2010ebday
 
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...Choosing the Right HTML5 Framework to Build your Mobile Web Application White...
Choosing the Right HTML5 Framework to Build your Mobile Web Application White...
 
Diving Into Xamarin.Forms
Diving Into Xamarin.Forms Diving Into Xamarin.Forms
Diving Into Xamarin.Forms
 
Smart Client Software Factory 2010
Smart Client Software Factory  2010Smart Client Software Factory  2010
Smart Client Software Factory 2010
 
MVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,MobileMVC(Model View Controller),Web,Enterprise,Mobile
MVC(Model View Controller),Web,Enterprise,Mobile
 
Over view of software artitecture
Over view of software artitectureOver view of software artitecture
Over view of software artitecture
 
Design Pattern
Design PatternDesign Pattern
Design Pattern
 
Design pattern
Design patternDesign pattern
Design pattern
 
MVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVCMVC Pattern. Flex implementation of MVC
MVC Pattern. Flex implementation of MVC
 
deliver:Agile 2019 "Testing Microservices: From Development to Production
deliver:Agile 2019 "Testing Microservices: From Development to Productiondeliver:Agile 2019 "Testing Microservices: From Development to Production
deliver:Agile 2019 "Testing Microservices: From Development to Production
 
Mvvm in the real world tccc10
Mvvm in the real world   tccc10Mvvm in the real world   tccc10
Mvvm in the real world tccc10
 

Recently uploaded

%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxalwaysnagaraju26
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyAnusha Are
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedDelhi Call girls
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfayushiqss
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456KiaraTiradoMicha
 

Recently uploaded (20)

%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
Pharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodologyPharm-D Biostatistics and Research methodology
Pharm-D Biostatistics and Research methodology
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verifiedSector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
Sector 18, Noida Call girls :8448380779 Model Escorts | 100% verified
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 

Architectural Guidance for Building Mobile Apps Using Xamarin.Forms

  • 1. Architectural Guidance for Building Mobile Apps Using Xamarin Forms Richard Taylor Vice President of Engineering SentryOne @rightincode – http://www.rightincode.com
  • 2.
  • 3. Who is Richard Taylor? Full Stack Software Engineer Lives in Huntersville, NC Organizer of CLT Xamarin Developers Lead Organizer of Modern Devs CLT http://www.rightincode.com @rightincode Vice President of Engineering Huntersville, NC http://www.sentryone.com @sentryone @rightincode - http://www.rightincode.com
  • 4. What are elements of a “good” software architecture?  Separation of Concerns  Single Responsibility Principle  Loose Coupling  Don’t Repeat Yourself (DRY) @rightincode - http://www.rightincode.com
  • 5. How can we achieve a “good” software architecture?  Use proven architectural styles Onion Architecture  Use proven architectural/design patterns MVVM (Model-View-ViewModel) Inversion of Control Dependency Injection @rightincode - http://www.rightincode.com
  • 6. Xamarin.Forms – Folder Structure @rightincode - http://www.rightincode.com Visual Studio Solution Explorer Reference Project: Tip Calculator
  • 7. Xamarin.Forms Architectural Guidance – MVVM  Design pattern that help facilitate the separation of the business and presentation logic from an applications user interface.  The why.. Separation of Concerns Support unit testing of the view model/model independently of the user interface Easier maintenance @rightincode - http://www.rightincode.com
  • 8. Xamarin.Forms Architectural Guidance – MVVM – cont. View  Responsible for the user interface View Model  Responsible for implementing of the properties and commands that the view binds to  Notifies the view when state changes  Coordinates all required interactions between the view and model @rightincode - http://www.rightincode.com
  • 9. Xamarin.Forms Architectural Guidance – MVVM – cont. Model  Represents the domain objects (data, business rules, validation) @rightincode - http://www.rightincode.com
  • 10. Xamarin.Forms Architectural Guidance – MVVM – cont. Options for implementation Manual (review reference application) Frameworks MvvmCross MVVM Light Prism @rightincode - http://www.rightincode.com
  • 11. Xamarin.Forms Architectural Guidance – Dependency Injection  Enables the decoupling of concrete types from the code that depends on the types  With DI, dependencies are provided by external facilities at runtime  DI is a form of Inversion of Control @rightincode - http://www.rightincode.com
  • 12. Xamarin.Forms Architectural Guidance – Dependency Injection – cont.  DI helps improve testability  DI does not require a container that houses the mapping between interfaces and their concrete types but DI containers are common @rightincode - http://www.rightincode.com
  • 13. Xamarin.Forms Architectural Guidance - Validation  Applications implementing the mvvm design pattern should perform validation in the view model and/or model  ValidatableObject<T> approach…  Properties of the view model/model that require validation should be of type ValidatableObject<T> that has validation rules defined in its Validations property  Validation is done by calling the Validate method of the ValidatableObject<T> which executes the validation rules on its Value property @rightincode - http://www.rightincode.com
  • 14. Xamarin.Forms Architectural Guidance – Validation – cont.  ValidatableObject<T> approach cont.  Errors are placed in the Error property of the ValidatableObject<T>  The IsValid property of the ValidatableObject<T> is updated to indicate if the validation succeeded or failed  For example, the entry view in Xamarin.Forms can be bound to the IsValid property and be notified if entered data is valid after validation and update the user interface accordingly @rightincode - http://www.rightincode.com
  • 15. Xamarin.Forms Architectural Guidance - Navigation  Support for navigation is built in and is considered view-first navigation  View-first navigation has some weaknesses  Tight coupling between views  Difficult to coordinate navigation across views and view models (i.e. initiating navigation from a view model)  Difficult to enforce business rules that impact navigation  Unit testing navigation is very difficult @rightincode - http://www.rightincode.com
  • 16. Xamarin.Forms Architectural Guidance - Navigation  View model-first navigation alternative  Can be achieved by implementing a custom navigation service or using one of the MVVM frameworks  Placing the navigation logic in the view model  Decouples views  Improves testability by allowing easier unit testing of navigation  Allows business rules to control navigation @rightincode - http://www.rightincode.com
  • 17. Xamarin.Forms Architectural Guidance – Component Communications  Typical communications between components are done using events which is a form of publish-subscribe communications  Works but… Requires tight coupling between components Results in the extended lifespan of components until all references are removed @rightincode - http://www.rightincode.com
  • 18. Xamarin.Forms Architectural Guidance – Component Communications  MessagingCenter Class  Implements the publish-subscribe pattern  Allows components to communicate without having a reference to each other  Allows components to be independently developed and tested  Publishers send messages and subscribers listen for messages they are interested in  Internally, the MessagingCenter Class uses weak references – it does not keep objects alive and allows them to be garbage collected @rightincode - http://www.rightincode.com
  • 19. Xamarin.Forms Architectural Guidance – Unit Testing @rightincode - http://www.rightincode.com Code
  • 20. Resources  Repo: (code) https://github.com/rightincode/TipCalcPro  Onion Architecture  http://blog.thedigitalgroup.com/chetanv/2015/07/06/und erstanding-onion-architecture/  Inversion of Control  https://martinfowler.com/articles/injection.html  Unit Testing  https://www.toptal.com/qa/how-to-write-testable-code- and-why-it-matters  Pluralsight Building a Pragmatic Unit Test Suite Writing Highly Maintainable Unit Tests Advance Unit Testing @rightincode - http://www.rightincode.com
  • 21. Resources  Enterprise Application Patterns using Xamarin.Forms  https://docs.microsoft.com/en-us/xamarin/xamarin- forms/enterprise-application-patterns/  Xamarin.Forms  https://docs.microsoft.com/en- us/xamarin/#pivot=platforms&panel=XamarinForms @rightincode - http://www.rightincode.com