Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

How to Structure Your Xamarin Solution by Adhering to Common .NET Practices - Xamarin Meetup Presentation

473 views

Published on

Slide of my presentation at Colombo Xamarin Meetups on July 2016 where we discussed How to Structure Your Xamarin Solution by Adhering to Common .NET Practices. We talked about Repository Pattern, Dependency Injection and Sitecore Mobile SDK for Xamarin

Published in: Mobile
  • Be the first to comment

  • Be the first to like this

How to Structure Your Xamarin Solution by Adhering to Common .NET Practices - Xamarin Meetup Presentation

  1. 1. How to Organise your Xamarin Solution by Adhering to Common .NET Development Practices Colombo Xamarin Meetup http://www.meetup.com/Colombo-Xamarin-Meetup/
  2. 2. About Me • Freelance Sitecore Consultant • Sitecore MVP 2016 • Blog - http://sitecorefootsteps.blogspot.com • YouTube - Sitecore for Dummies • Initiator & Co-Founder - Sitecore User Group Sri Lanka
  3. 3. What We Going To Discuss • Discuss a Simple Application to implement best practices • How and why we implement Repository Pattern into the solution • Dependency Injection • Xamarin Forms Dependency Service • Example application with Xamarin for Sitecore which uses Sitecore Mobile API
  4. 4. Simple Application • Home Screen • Calculation Screen • Two Input Fields • On Calculate button clicked, Results Display • Results keep in a Repository (memory in this case) • When your return, you can see the last calculated result
  5. 5. What Can Be Improved ? • UI and Logic Layer in one place • Code maintenance is hard • Hard to work in same functionality for two developers (ex: UI & Backend Devs) • Hard to replace UI with new Technology
  6. 6. Improvement 1 Moving Application Logic into a Service Layer • Easy to Maintain • Easy for Backend and Front- end Developers to Work in Same Functionality • Easy to Replace UI Layer
  7. 7. What Can Be Improved ? • Data Storage is also Handled in Service Layer • Hard to Change Storage Mechanism • Service Layer implementation needs to wait till Full Storage functionality implemented
  8. 8. Improvement 2 Moving Data Storage Functionality Into Repository Layer • Ease to Maintain • Ease to Replace Storage Media • Can Start Developing Functionality without Waiting for Storage Functionality
  9. 9. Repository Pattern • Separates Data Access Layer from Logic Layer • Retrieve data from data sources and convert them to Domain Objects, and pass them to Service Layer
  10. 10. What Can Be Improved ? • One Layer is Dependent on Classes of Other Layer • Tight Coupling
  11. 11. Improvement 3 Dependency Injection • Used to resolve dependencies • DI Containers : Autofac, Ninject, StructureMap, Castle Windsor, etc • In this example, we use Autofac 3.5.2 • Light-Weight
  12. 12. DependencyService
  13. 13. DependencyService • Allow to Register different implementation of an Interface for each Target Platform • Framework uses correct implementation depending on the platform • Need to place Dependency Attribute before the Class Implementation
  14. 14. Disadvantages of DependencyService • It is considered as Anti-Pattern • Adding a Dependency Attribute on Classes tightly couples DI framework being used • Hard to write Unit Tests
  15. 15. Improvement 4 Using DI to Replace DependencyService
  16. 16. Sitecore CMS • One of the leading Content Management System in the world • Provides a Mobile SDK for Xamarin
  17. 17. Simple App Calling Sitecore Mobile SDK • Sitecore Mobile SDK - a Portable .NET Library • Provides an interface to work on Sitecore CMS • Need to Implement your application methods as async calls
  18. 18. What We Did NOT Discussed • MVVM Pattern • Xamarin INotifyPropertyChange Interface • Object-to-Object Mappers
  19. 19. Thank You! Source Code : https://github.com/chaturangar/xamarin-footsteps

×