MVP Mix 2015 Leveraging MVVM on all Platforms

  • Published on
    15-Jul-2015

  • View
    200

  • Download
    4

Embed Size (px)

Transcript

<ul><li><p>Whos this guy?</p></li><li><p>Whos this guy really?</p><p>JamesMontemagno</p><p>Developer Evangelist </p><p>james@xamarin.com http://motz.codes @JamesMontemagno </p></li><li><p>MVVM is awesome and will revolutionize your application development process. </p><p>-James Montemagno </p></li><li><p>Lets talk architecture!</p><p>(everyone loves architecture..) </p></li><li><p>Why do we architect our code?</p><p> Organization &amp; Maintainability of Code Abstract away all business logic Code re-use Make our views dumb and replaceable Our architect told us to</p></li><li><p>ALL THE PLATFORMS!</p></li><li><p>What is MVC?</p></li><li><p>Model-View-Controller</p><p>Model </p><p>View Controller </p><p>Updates </p><p>Sees Uses </p><p>Manipulates </p></li><li><p>What is MVVM?</p></li><li><p>Model-View-ViewModel</p><p>Model View ViewModel </p><p>How to display information </p><p>What to display Flow of interaction </p><p>Business Logic Data objects </p><p>Events </p><p>Data Data </p><p>Platform Specific Portable </p></li><li><p>Why MVVM?</p></li><li><p>!View Models!</p><p>(Properties, Commands, etc.)!!</p><p>Models: Data, Services, Etc. Models: Data, Services, Etc. </p></li><li><p>Why MVVM?</p><p> Organization &amp; Maintainability of Code Abstract away all business logic Code re-use Make our views dumb and replaceable Our architect told us to</p></li><li><p>MVVM != Data Binding</p></li><li><p>MVVM Framework == Data Binding</p></li><li><p>Model-View-ViewModel</p><p>Model View ViewModel </p><p>Magic Binding Framework Here </p></li><li><p>Model-View-ViewModel</p><p>Model View ViewModel </p><p>1 Action </p><p>2 Event Handling </p><p>3 Command 4 Access Data </p><p>5 Notify change </p><p>6 Get Changed Data </p><p>7 Update UI </p><p>Click </p><p>Hello! </p><p>Magic Binder </p></li><li><p>Microsoft World</p><p> Built into: Windows Phone Windows Store WPF</p><p> Provides: Data Binding Command</p><p> Does NOT Provide Navigation IoC Messaging Other Fun Stuff</p></li><li><p>Live Coding Adventure</p></li><li><p>What Did We Just See?</p><p> INotifyPropertyChanged Notifies UI of Changes Check value changed </p><p>before value changes Enables Databinding</p><p> ICommand Contract for Commanding Optional parameters Can Execute </p><p> Used to enable/disable Manually must trigger when </p><p>property changes</p></li><li><p>Services</p><p>ViewModel IStockService </p><p>Yahoo </p><p>SQLite </p><p>Azure </p><p>TestStockServices </p></li><li><p>View Services</p><p>ViewModel IDialog </p><p>WPF </p><p>iOS/Android </p><p>Windows Phone </p><p>TestDialogServices </p></li><li><p>View Services In Action</p><p>var av = new UIAlertView( title, message, null, buttonText, null); av.Show(); </p><p>var builder = new AlertDialog.Builder( ActivityBase.CurrentActivity); builder.SetMessage(message); if (!string.IsNullOrEmpty(title)) { builder.SetTitle(title); } builder.SetPositiveButton( buttonConfirmText, null); return builder; </p><p>MessageBox.Show( message, title ?? string.Empty, MessageBoxButton.OK); </p><p>Android iOS Windows Phone </p></li><li><p>View Services In Action</p></li><li><p>What about.</p></li><li><p>Silo Approach</p><p>Build Apps !Multiple Times!</p></li><li><p>Not Really Built for MVVM L</p></li><li><p>Native With !Code Sharing!</p><p>Xamarins Unique Approach</p></li><li><p>Bind</p><p> Simple two-way data binding Open source: https://github.com/praeclarum/Bind</p></li><li><p>Live Coding Adventure</p></li><li><p>Full Frameworks</p><p> Data Binding Commands Navigation IoC Plugins So Much More</p></li><li><p>Even More</p><p>MVVM Light MVVMCross Xamarin.Forms</p></li><li><p>Live Coding Adventure</p></li><li><p>What about the Web?</p></li><li><p>To Recap</p><p> MVVM More maintainable code More testable code Ability to abstract platform differences Just a pattern</p><p> MVVM Framework Brings in data binding Speeds up repetitive work</p></li><li><p>MVVM ==</p><p>Tim &amp; Eric Awesome Show GIF </p></li><li><p>Resources</p><p> MVVM Awesome Microsoft Docs</p><p> bit.ly/ms-mvvm MVVM Light + Xamarin</p><p> bit.ly/mvvmlight-xamarin Xamarin.Forms + XAML &amp; MVVM</p><p> bit.ly/xamarin-forms-mvvm MVVMCross </p><p> https://github.com/MvvmCross/MvvmCross MVVM Announcement Blog by John Gossman</p><p> http://blogs.msdn.com/b/johngossman/archive/2005/10/08/478683.aspx</p></li><li><p>Get Started Xamarin.com</p></li><li><p>Thank you!Q&amp;A</p><p>JamesMontemagno</p><p>Developer Evangelist </p><p>james@xamarin.com http://motz.codes @JamesMontemagno </p></li></ul>