SlideShare une entreprise Scribd logo
1  sur  50
Télécharger pour lire hors ligne
MvvmCross Introduction

    13th December 2012
          @slodge
Presentation Model


Represent the state and behavior of the presentation
   independently of the GUI controls used in the
                      interface.




             http://martinfowler.com/eaaDev/PresentationModel.html
In 2005…

      Model/View/ViewModel is a variation of
Model/View/Controller that is tailored for modern UI
   development platforms where the View is the
  responsibility of a designer rather than a classic
                      developer.


                            Tales from the Smart Client, John Grossman
  http://blogs.msdn.com/b/johngossman/archive/2005/10/08/478683.aspx
Also in 2005…
• 10 years of dev – C++, C, VB, Java, JavaScript,
  LISP, SmallTalk, Delphi, …
• A year off travelling
  – from Argentina to Zambia
• DeveloperDeveloperDeveloper
• 1 conclusion:
MvvmCross Introduction
   Evolving the dinosaur
    13th December 2012
          @slodge
What we’ll cover…
•   MVVM Theory
•   .Net MVVM
•   A practical example – some code!
•   Interface Driven Development
    – Portable Class Libraries
    – Unit Testing
    – Plugins
• Some examples
What we’ll cover…
•   MVVM Theory
•   .Net MVVM
•   A practical example – some code!
•   Interface Driven Development
    – Portable Class Libraries
    – Unit Testing
    – Plugins
• Some examples
M-V-VM
Detailed flow
What we’ll cover…
•   MVVM Theory
•   .Net MVVM
•   A practical example – some code!
•   Interface Driven Development
    – Portable Class Libraries
    – Unit Testing
    – Plugins
• Some examples
ViewModels Public Properties

private bool _isSearching;
public bool IsSearching
{
     get { return _isSearching; }
     set
     {
          _isSearching = value;
          RaisePropertyChanged("IsSearching");
     }
}
For ViewModel Changes

public interface INotifyPropertyChanged
{
     event PropertyChangedEventHandler PropertyChanged;
}


public class PropertyChangedEventArgs : EventArgs
{
     public string PropertyName { get; }
}
For Collections
public interface INotifyCollectionChanged
{
     event NotifyCollectionChangedEventHandler CollectionChanged;
}

public enum NotifyCollectionChangedAction
{
     Add, Remove, Replace, Move, Reset,
}

public class NotifyCollectionChangedEventArgs : EventArg
{
     public NotifyCollectionChangedAction Action { get; }
     public IList NewItems { get; }
     public IList OldItems { get; }
     public int NewStartingIndex { get; }
     public int OldStartingIndex { get; }
}
For Actions


public interface ICommand
{
    event EventHandler CanExecuteChanged;
    bool CanExecute(object parameter);
    void Execute(object parameter);
}
.Net Implementation


     ICommand
  Public Property Set



   INotifyPropertyChanged
  INotifyCollectionChanged
     Public Property Get
Why?
To Enable
• Awesome UI and Data Development
• Unit Testing of code
• Large applications to have a common
  architecture
• Different platforms can share code
What we’ll cover…
•   MVVM Theory
•   .Net MVVM
•   A practical example – some code!
•   Interface Driven Development
    – Portable Class Libraries
    – Unit Testing
    – Plugins
• Some examples
What is MvvmCross?


      Code!
Code evolution I
•   Single Mono for Android Project
•   Good separation of UI from ‘Model’ code
•   Simple – it works
•   But:
    – No testing
    – No testability
    – Portability by cut/paste
Code Evolution 2
• MvvmCross Library switched in
  – PCL code
  – Formal DI/IoC used
• On UI:
  – DataBinding arrived
  – Code got much thinner!
  – XML got bigger
• Not all win:
  – External Dependencies got larger
  – Code overall increased in size
Code Evolution 3
• Cross Platform
• All UIs MVVM
• 100% shared application
  logic
• 100% shared test harness
Data-Binding
WP/WinRT
 99% Xaml




   Droid
Mainly Axml
Some .Dialog




  Touch
Some .Dialog
 Some .XIB
  Some C#
What we’ll cover…
•   MVVM Theory
•   .Net MVVM
•   A practical example – some code!
•   Interface Driven Development
    – Portable Class Libraries
    – Unit Testing
    – Plugins
• Some examples
Portable Class Libraries
Unit Testing
“I get paid for code that works, not for tests, so my
philosophy is to test as little as possible to reach a
given level of confidence.
…
When coding on a team, I modify my strategy to
carefully test code that we, collectively, tend to get
wrong.”
                                                Kent Beck
                http://stackoverflow.com/questions/153234/how-deep-are-your-unit-tests
Plugin – Native abstractions
1. Declare common functionality (an interface)
   public interface IMvxComposeEmailTask
   {
       void ComposeEmail(string to, string cc, string subject, string body, bool isHtml);
   }

2. Write platform specific implementations
  public class MvxComposeEmailTask : MvxWindowsPhoneTask, IMvxComposeEmailTask
  {
       public void ComposeEmail(string to, string cc, string subject, string body, bool isHtml)
       {
           var task = new EmailComposeTask() { To = to, Subject = subject, Cc = cc, Body = body };
           DoWithInvalidOperationProtection(task.Show);
       }
    }

3. In apps, use the interface and not the implementation
   protected void ComposeEmail(string to, string subject, string body)
   {
        Cirrious.MvvmCross.Plugins.Email.PluginLoader.Instance.EnsureLoaded();
        var task = this.GetService<IMvxComposeEmailTask>();
        task.ComposeEmail(to, null, subject, body, false);
   }
Sphero – Plugin Magic
• Plugin Magic

• Each Plugin:
   – 1 PCL
   – 1 Assembly per platform
Why?
To Enable
• Awesome UI and Data Development
• Unit Testing of code
• Large applications to have a common
  architecture
• Different platforms can share code
What we’ll cover…
•   MVVM Theory
•   .Net MVVM
•   A practical example – some code!
•   Interface Driven Development
    – Portable Class Libraries
    – Unit Testing
    – Plugins
• Some examples
MonoCross
A team in a galaxy far far away




@imaji @mrlacey @sichy @slodge @touch4apps …
Redth in Canada




https://github.com/Redth/WshLst/
Rune in Norway




https://github.com/runegri/CrossBox
Jason in UK




http://www.aviva.co.uk/drive/
CheeseBaron in Denmark




http://blog.ostebaronen.dk/
Greg in NYC




http://bit.ly/mvxgshac
JSON.Net Downunder (?)
Olivier in France




http://www.e-naxos.com/UsIndex.html
Dan in Italy




http://bit.ly/mvxDanA
Zoldeper in Hungary?




https://github.com/Zoldeper/Blooor
Daniel in Redmond




http://channel9.msdn.com/Events/Build/2012/3-004
What we’ve covered…
•   MVVM Theory
•   .Net MVVM
•   A practical example – some code!
•   Interface Driven Development
    – Portable Class Libraries
    – Unit Testing
    – Plugins
• Some examples
To join in…
If you want to join in:
   •   Tool up
   •   Share
   •   Reuse
   •   Test
   •   Architect
MS-PL on GitHub




http://github.com/slodge/MvvmCross
Some other talks available




http://bit.ly/mvxTweetPic
C# - 1 Stack - Cloud to Mobile
Data Access

Business Logic

Presentation


Service Consumption         Local Data/Services

Business Logic

UI Logic

WP7                   iOS   Droid                 Win8
Not as cool as dinosaurs
Data Access

Business Logic

Presentation


Service Consumption         Local Data/Services

Business Logic

UI Logic

WP7                   iOS   Droid                 Win8
Some credits
Images from Wikipedia Commons:
•   http://en.wikipedia.org/wiki/File:Macronaria_scrubbed_enh.jpg
•   http://en.wikipedia.org/wiki/File:Human-
    eoraptor_size_comparison%28v2%29.png



Diagrams from Java – ZK
•   http://books.zkoss.org/wiki/ZK_Developer%27s_Reference/MVVM



Sample projects as credited inline
Thanks for listening…
http://cirrious.com

http://slodge.blogspot.com
http://github.com/slodge/mvvmcross

me@slodge.com
@slodge

Stuart Lodge,
I’m a Dinosaur
Xamarin
               Seminar
Please give us your feedback
              http://bit.ly/xamfeedback


Follow us on Twitter
                       @XamarinHQ

13th December 2012

Contenu connexe

Tendances

Tendances (20)

JavaScript Engine and WebAssembly
JavaScript Engine and WebAssemblyJavaScript Engine and WebAssembly
JavaScript Engine and WebAssembly
 
What is Mean Stack Development ?
What is Mean Stack Development ?What is Mean Stack Development ?
What is Mean Stack Development ?
 
LAMP is so yesterday, MEAN is so tomorrow! :)
LAMP is so yesterday, MEAN is so tomorrow! :) LAMP is so yesterday, MEAN is so tomorrow! :)
LAMP is so yesterday, MEAN is so tomorrow! :)
 
Mean PPT
Mean PPTMean PPT
Mean PPT
 
Web assembly: a brief overview
Web assembly: a brief overviewWeb assembly: a brief overview
Web assembly: a brief overview
 
learn mvc project in 7 day
learn mvc project in 7 daylearn mvc project in 7 day
learn mvc project in 7 day
 
Mean stack
Mean stackMean stack
Mean stack
 
MEAN Stack
MEAN Stack MEAN Stack
MEAN Stack
 
Migrating MVVM Applications to HTML5
Migrating MVVM Applications to HTML5Migrating MVVM Applications to HTML5
Migrating MVVM Applications to HTML5
 
Building Isomorphic Apps (JSConf.Asia 2014)
Building Isomorphic Apps (JSConf.Asia 2014)Building Isomorphic Apps (JSConf.Asia 2014)
Building Isomorphic Apps (JSConf.Asia 2014)
 
The MEAN Stack
The MEAN StackThe MEAN Stack
The MEAN Stack
 
MEAN Stack
MEAN StackMEAN Stack
MEAN Stack
 
The beauty in building .NET libraries - Embracing .NET Standard
The beauty in building .NET libraries - Embracing .NET StandardThe beauty in building .NET libraries - Embracing .NET Standard
The beauty in building .NET libraries - Embracing .NET Standard
 
Understanding The MVVM Pattern (TechDays Belgium)
Understanding The MVVM Pattern (TechDays Belgium)Understanding The MVVM Pattern (TechDays Belgium)
Understanding The MVVM Pattern (TechDays Belgium)
 
XAML/C# to HTML5/JS
XAML/C#  to HTML5/JS XAML/C#  to HTML5/JS
XAML/C# to HTML5/JS
 
Get MEAN! Node.js and the MEAN stack
Get MEAN!  Node.js and the MEAN stackGet MEAN!  Node.js and the MEAN stack
Get MEAN! Node.js and the MEAN stack
 
Introduction to mean stack
Introduction to mean stackIntroduction to mean stack
Introduction to mean stack
 
MEAN Stack - Introduction & Advantages - Why should you switch to MEAN stack ...
MEAN Stack - Introduction & Advantages - Why should you switch to MEAN stack ...MEAN Stack - Introduction & Advantages - Why should you switch to MEAN stack ...
MEAN Stack - Introduction & Advantages - Why should you switch to MEAN stack ...
 
JSConf US 2014: Building Isomorphic Apps
JSConf US 2014: Building Isomorphic AppsJSConf US 2014: Building Isomorphic Apps
JSConf US 2014: Building Isomorphic Apps
 
JavaScript Framework Smackdown
JavaScript Framework SmackdownJavaScript Framework Smackdown
JavaScript Framework Smackdown
 

En vedette

En vedette (8)

Oakland athletics-stadium-locations
Oakland athletics-stadium-locationsOakland athletics-stadium-locations
Oakland athletics-stadium-locations
 
Cross-Platform Native Apps with JavaScript
Cross-Platform Native Apps with JavaScriptCross-Platform Native Apps with JavaScript
Cross-Platform Native Apps with JavaScript
 
ISSPublic
ISSPublicISSPublic
ISSPublic
 
Design and develop cross-platform mobile apps using MVVMCross
Design and develop cross-platform mobile apps using MVVMCrossDesign and develop cross-platform mobile apps using MVVMCross
Design and develop cross-platform mobile apps using MVVMCross
 
MvvmCross
MvvmCrossMvvmCross
MvvmCross
 
Cross Plattform App Entwicklung mit Visual Studio 2015 (Xamarin und Cordova)
Cross Plattform App Entwicklung mit Visual Studio 2015 (Xamarin und Cordova)Cross Plattform App Entwicklung mit Visual Studio 2015 (Xamarin und Cordova)
Cross Plattform App Entwicklung mit Visual Studio 2015 (Xamarin und Cordova)
 
De la idea al proyecto. Como transformar ideas en proyectos de forma agil
De la idea al proyecto. Como transformar ideas en proyectos de forma agilDe la idea al proyecto. Como transformar ideas en proyectos de forma agil
De la idea al proyecto. Como transformar ideas en proyectos de forma agil
 
SRS FOR CHAT APPLICATION
SRS FOR CHAT APPLICATIONSRS FOR CHAT APPLICATION
SRS FOR CHAT APPLICATION
 

Similaire à MvvmCross Seminar

Similaire à MvvmCross Seminar (20)

TypeScript - Javascript done right
TypeScript - Javascript done rightTypeScript - Javascript done right
TypeScript - Javascript done right
 
Latest trends in information technology
Latest trends in information technologyLatest trends in information technology
Latest trends in information technology
 
Training: MVVM Pattern
Training: MVVM PatternTraining: MVVM Pattern
Training: MVVM Pattern
 
Get Started with JavaScript Frameworks
Get Started with JavaScript FrameworksGet Started with JavaScript Frameworks
Get Started with JavaScript Frameworks
 
An introduction to Node.js
An introduction to Node.jsAn introduction to Node.js
An introduction to Node.js
 
Meetup. Technologies Intro for Non-Tech People
Meetup. Technologies Intro for Non-Tech PeopleMeetup. Technologies Intro for Non-Tech People
Meetup. Technologies Intro for Non-Tech People
 
Node.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel AvivNode.js meetup at Palo Alto Networks Tel Aviv
Node.js meetup at Palo Alto Networks Tel Aviv
 
Java1 in mumbai
Java1 in mumbaiJava1 in mumbai
Java1 in mumbai
 
The NRB Group mainframe day 2021 - Containerisation on Z - Paul Pilotto - Seb...
The NRB Group mainframe day 2021 - Containerisation on Z - Paul Pilotto - Seb...The NRB Group mainframe day 2021 - Containerisation on Z - Paul Pilotto - Seb...
The NRB Group mainframe day 2021 - Containerisation on Z - Paul Pilotto - Seb...
 
The Future of Cloud Innovation, featuring Adrian Cockcroft
The Future of Cloud Innovation, featuring Adrian CockcroftThe Future of Cloud Innovation, featuring Adrian Cockcroft
The Future of Cloud Innovation, featuring Adrian Cockcroft
 
Stackato v5
Stackato v5Stackato v5
Stackato v5
 
Containers: DevOp Enablers of Technical Solutions
Containers: DevOp Enablers of Technical SolutionsContainers: DevOp Enablers of Technical Solutions
Containers: DevOp Enablers of Technical Solutions
 
Node.js In The Enterprise - A Primer
Node.js In The Enterprise - A PrimerNode.js In The Enterprise - A Primer
Node.js In The Enterprise - A Primer
 
Mobile app-and-microservices-with-ibm-cloud
Mobile app-and-microservices-with-ibm-cloudMobile app-and-microservices-with-ibm-cloud
Mobile app-and-microservices-with-ibm-cloud
 
Demystifying Containerization Principles for Data Scientists
Demystifying Containerization Principles for Data ScientistsDemystifying Containerization Principles for Data Scientists
Demystifying Containerization Principles for Data Scientists
 
Stackato v6
Stackato v6Stackato v6
Stackato v6
 
Microservice pitfalls
Microservice pitfalls Microservice pitfalls
Microservice pitfalls
 
Reaktive Programmierung mit den Reactive Extensions (Rx)
Reaktive Programmierung mit den Reactive Extensions (Rx)Reaktive Programmierung mit den Reactive Extensions (Rx)
Reaktive Programmierung mit den Reactive Extensions (Rx)
 
The State of the Veil Framework
The State of the Veil FrameworkThe State of the Veil Framework
The State of the Veil Framework
 
Application Centric Microservices from Redhat Summit 2015
Application Centric Microservices from Redhat Summit 2015Application Centric Microservices from Redhat Summit 2015
Application Centric Microservices from Redhat Summit 2015
 

Plus de Xamarin

Plus de Xamarin (20)

Xamarin University Presents: Building Your First Intelligent App with Xamarin...
Xamarin University Presents: Building Your First Intelligent App with Xamarin...Xamarin University Presents: Building Your First Intelligent App with Xamarin...
Xamarin University Presents: Building Your First Intelligent App with Xamarin...
 
Xamarin University Presents: Ship Better Apps with Visual Studio App Center
Xamarin University Presents: Ship Better Apps with Visual Studio App CenterXamarin University Presents: Ship Better Apps with Visual Studio App Center
Xamarin University Presents: Ship Better Apps with Visual Studio App Center
 
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for XamarinGet the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
 
Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Get the Most out of Android 8 Oreo with Visual Studio Tools for XamarinGet the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
Get the Most out of Android 8 Oreo with Visual Studio Tools for Xamarin
 
Creative Hacking: Delivering React Native App A/B Testing Using CodePush
Creative Hacking: Delivering React Native App A/B Testing Using CodePushCreative Hacking: Delivering React Native App A/B Testing Using CodePush
Creative Hacking: Delivering React Native App A/B Testing Using CodePush
 
Build Better Games with Unity and Microsoft Azure
Build Better Games with Unity and Microsoft AzureBuild Better Games with Unity and Microsoft Azure
Build Better Games with Unity and Microsoft Azure
 
Exploring UrhoSharp 3D with Xamarin Workbooks
Exploring UrhoSharp 3D with Xamarin WorkbooksExploring UrhoSharp 3D with Xamarin Workbooks
Exploring UrhoSharp 3D with Xamarin Workbooks
 
Desktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Desktop Developer’s Guide to Mobile with Visual Studio Tools for XamarinDesktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
Desktop Developer’s Guide to Mobile with Visual Studio Tools for Xamarin
 
Developer’s Intro to Azure Machine Learning
Developer’s Intro to Azure Machine LearningDeveloper’s Intro to Azure Machine Learning
Developer’s Intro to Azure Machine Learning
 
Customizing Xamarin.Forms UI
Customizing Xamarin.Forms UICustomizing Xamarin.Forms UI
Customizing Xamarin.Forms UI
 
Session 4 - Xamarin Partner Program, Events and Resources
Session 4 - Xamarin Partner Program, Events and ResourcesSession 4 - Xamarin Partner Program, Events and Resources
Session 4 - Xamarin Partner Program, Events and Resources
 
Session 3 - Driving Mobile Growth and Profitability
Session 3 - Driving Mobile Growth and ProfitabilitySession 3 - Driving Mobile Growth and Profitability
Session 3 - Driving Mobile Growth and Profitability
 
Session 2 - Emerging Technologies in your Mobile Practice
Session 2 - Emerging Technologies in your Mobile PracticeSession 2 - Emerging Technologies in your Mobile Practice
Session 2 - Emerging Technologies in your Mobile Practice
 
Session 1 - Transformative Opportunities in Mobile and Cloud
Session 1 - Transformative Opportunities in Mobile and Cloud Session 1 - Transformative Opportunities in Mobile and Cloud
Session 1 - Transformative Opportunities in Mobile and Cloud
 
SkiaSharp Graphics for Xamarin.Forms
SkiaSharp Graphics for Xamarin.FormsSkiaSharp Graphics for Xamarin.Forms
SkiaSharp Graphics for Xamarin.Forms
 
Building Games for iOS, macOS, and tvOS with Visual Studio and Azure
Building Games for iOS, macOS, and tvOS with Visual Studio and AzureBuilding Games for iOS, macOS, and tvOS with Visual Studio and Azure
Building Games for iOS, macOS, and tvOS with Visual Studio and Azure
 
Intro to Xamarin.Forms for Visual Studio 2017
Intro to Xamarin.Forms for Visual Studio 2017Intro to Xamarin.Forms for Visual Studio 2017
Intro to Xamarin.Forms for Visual Studio 2017
 
Connected Mobile Apps with Microsoft Azure
Connected Mobile Apps with Microsoft AzureConnected Mobile Apps with Microsoft Azure
Connected Mobile Apps with Microsoft Azure
 
Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017Introduction to Xamarin for Visual Studio 2017
Introduction to Xamarin for Visual Studio 2017
 
Building Your First iOS App with Xamarin for Visual Studio
Building Your First iOS App with Xamarin for Visual StudioBuilding Your First iOS App with Xamarin for Visual Studio
Building Your First iOS App with Xamarin for Visual Studio
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Dernier (20)

Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 

MvvmCross Seminar

  • 1. MvvmCross Introduction 13th December 2012 @slodge
  • 2. Presentation Model Represent the state and behavior of the presentation independently of the GUI controls used in the interface. http://martinfowler.com/eaaDev/PresentationModel.html
  • 3. In 2005… Model/View/ViewModel is a variation of Model/View/Controller that is tailored for modern UI development platforms where the View is the responsibility of a designer rather than a classic developer. Tales from the Smart Client, John Grossman http://blogs.msdn.com/b/johngossman/archive/2005/10/08/478683.aspx
  • 4. Also in 2005… • 10 years of dev – C++, C, VB, Java, JavaScript, LISP, SmallTalk, Delphi, … • A year off travelling – from Argentina to Zambia • DeveloperDeveloperDeveloper • 1 conclusion:
  • 5. MvvmCross Introduction Evolving the dinosaur 13th December 2012 @slodge
  • 6. What we’ll cover… • MVVM Theory • .Net MVVM • A practical example – some code! • Interface Driven Development – Portable Class Libraries – Unit Testing – Plugins • Some examples
  • 7. What we’ll cover… • MVVM Theory • .Net MVVM • A practical example – some code! • Interface Driven Development – Portable Class Libraries – Unit Testing – Plugins • Some examples
  • 10. What we’ll cover… • MVVM Theory • .Net MVVM • A practical example – some code! • Interface Driven Development – Portable Class Libraries – Unit Testing – Plugins • Some examples
  • 11. ViewModels Public Properties private bool _isSearching; public bool IsSearching { get { return _isSearching; } set { _isSearching = value; RaisePropertyChanged("IsSearching"); } }
  • 12. For ViewModel Changes public interface INotifyPropertyChanged { event PropertyChangedEventHandler PropertyChanged; } public class PropertyChangedEventArgs : EventArgs { public string PropertyName { get; } }
  • 13. For Collections public interface INotifyCollectionChanged { event NotifyCollectionChangedEventHandler CollectionChanged; } public enum NotifyCollectionChangedAction { Add, Remove, Replace, Move, Reset, } public class NotifyCollectionChangedEventArgs : EventArg { public NotifyCollectionChangedAction Action { get; } public IList NewItems { get; } public IList OldItems { get; } public int NewStartingIndex { get; } public int OldStartingIndex { get; } }
  • 14. For Actions public interface ICommand { event EventHandler CanExecuteChanged; bool CanExecute(object parameter); void Execute(object parameter); }
  • 15. .Net Implementation ICommand Public Property Set INotifyPropertyChanged INotifyCollectionChanged Public Property Get
  • 16. Why? To Enable • Awesome UI and Data Development • Unit Testing of code • Large applications to have a common architecture • Different platforms can share code
  • 17. What we’ll cover… • MVVM Theory • .Net MVVM • A practical example – some code! • Interface Driven Development – Portable Class Libraries – Unit Testing – Plugins • Some examples
  • 19. Code evolution I • Single Mono for Android Project • Good separation of UI from ‘Model’ code • Simple – it works • But: – No testing – No testability – Portability by cut/paste
  • 20. Code Evolution 2 • MvvmCross Library switched in – PCL code – Formal DI/IoC used • On UI: – DataBinding arrived – Code got much thinner! – XML got bigger • Not all win: – External Dependencies got larger – Code overall increased in size
  • 21. Code Evolution 3 • Cross Platform • All UIs MVVM • 100% shared application logic • 100% shared test harness
  • 22. Data-Binding WP/WinRT 99% Xaml Droid Mainly Axml Some .Dialog Touch Some .Dialog Some .XIB Some C#
  • 23. What we’ll cover… • MVVM Theory • .Net MVVM • A practical example – some code! • Interface Driven Development – Portable Class Libraries – Unit Testing – Plugins • Some examples
  • 25. Unit Testing “I get paid for code that works, not for tests, so my philosophy is to test as little as possible to reach a given level of confidence. … When coding on a team, I modify my strategy to carefully test code that we, collectively, tend to get wrong.” Kent Beck http://stackoverflow.com/questions/153234/how-deep-are-your-unit-tests
  • 26. Plugin – Native abstractions 1. Declare common functionality (an interface) public interface IMvxComposeEmailTask { void ComposeEmail(string to, string cc, string subject, string body, bool isHtml); } 2. Write platform specific implementations public class MvxComposeEmailTask : MvxWindowsPhoneTask, IMvxComposeEmailTask { public void ComposeEmail(string to, string cc, string subject, string body, bool isHtml) { var task = new EmailComposeTask() { To = to, Subject = subject, Cc = cc, Body = body }; DoWithInvalidOperationProtection(task.Show); } } 3. In apps, use the interface and not the implementation protected void ComposeEmail(string to, string subject, string body) { Cirrious.MvvmCross.Plugins.Email.PluginLoader.Instance.EnsureLoaded(); var task = this.GetService<IMvxComposeEmailTask>(); task.ComposeEmail(to, null, subject, body, false); }
  • 27. Sphero – Plugin Magic • Plugin Magic • Each Plugin: – 1 PCL – 1 Assembly per platform
  • 28. Why? To Enable • Awesome UI and Data Development • Unit Testing of code • Large applications to have a common architecture • Different platforms can share code
  • 29. What we’ll cover… • MVVM Theory • .Net MVVM • A practical example – some code! • Interface Driven Development – Portable Class Libraries – Unit Testing – Plugins • Some examples
  • 31. A team in a galaxy far far away @imaji @mrlacey @sichy @slodge @touch4apps …
  • 42. What we’ve covered… • MVVM Theory • .Net MVVM • A practical example – some code! • Interface Driven Development – Portable Class Libraries – Unit Testing – Plugins • Some examples
  • 43. To join in… If you want to join in: • Tool up • Share • Reuse • Test • Architect
  • 45. Some other talks available http://bit.ly/mvxTweetPic
  • 46. C# - 1 Stack - Cloud to Mobile Data Access Business Logic Presentation Service Consumption Local Data/Services Business Logic UI Logic WP7 iOS Droid Win8
  • 47. Not as cool as dinosaurs Data Access Business Logic Presentation Service Consumption Local Data/Services Business Logic UI Logic WP7 iOS Droid Win8
  • 48. Some credits Images from Wikipedia Commons: • http://en.wikipedia.org/wiki/File:Macronaria_scrubbed_enh.jpg • http://en.wikipedia.org/wiki/File:Human- eoraptor_size_comparison%28v2%29.png Diagrams from Java – ZK • http://books.zkoss.org/wiki/ZK_Developer%27s_Reference/MVVM Sample projects as credited inline
  • 50. Xamarin Seminar Please give us your feedback http://bit.ly/xamfeedback Follow us on Twitter @XamarinHQ 13th December 2012