Mobile Zone is brought to you in partnership with:

My name is Bruno Terkaly and I am a Developer Evangelist in Northern California. Over the past few months I have been presenting a wide variety of demos and slides highlighting the wealth of new features in Visual Studio 2008. Bruno is a DZone MVB and is not an employee of DZone and has posted 51 posts at DZone. You can read more from them at their website. View Full User Profile

Migrating iOS MVC Apps to Windows Phone 8

01.22.2013
| 4378 views |
  • submit to reddit
  1. Recently, I’ve been working with several local iOS developers wishing to port their application to the Windows 8 and Windows Phone 8 platforms. I have been assisting them with this journey.
  2. Many iOS developers leverage the MVC pattern in their applications. They have been asking me for an equivalent framework in the Windows Phone 8 world as well as Windows 8.
  3. This post is about getting iOS developers up to speed on implementing their MVC applications on Windows (Phone 8/8). The goal is to understand the equivalent constructs in the Windows world, so that migration of iOS MVC apps to Windows 8 is straightforward.
  4. Most app developers realize that being first into a marketplace helps ensure success. The Windows 8 store and the Windows phone eight store are relatively new, and as a result, offer great opportunities should the platform really take off.
  5. There are hundreds of millions of Windows operating systems out in the wild. Even if up small percentage upgrade to Windows 8, there are substantial opportunities for app developers.

espbyhyv
  1. iOS leverages The Model-View-Controller (MVC) design pattern
  2. The pattern defines the roles objects play in the application
  3. Also defines the way objects communicate with each other
  4. Each object has roles
  5. There are 3 roles:
    • Model
      • Encapsulates the data specific to an application and define the logic and computation that manipulate and process that data
      • Gets updated by controller
      • Notifies controller when data changes
    • View
      • Encapsulates application that users can see. Views draw themselves
      • Gets updated by controller
      • Tells controller about user action
    • Controller
      • Represents the intermediary between one or more of an application’s view objects and one or more of its model objects.
      • It can update the model with new data. It is notified by the model when data changes
      • It updates the view
      • It can be affected by user actions in the view

f5q5q3sf
  1. Core data
    • Core Data is a schema-driven object graph management and persistence framework. Fundamentally, Core Data helps you to save model objects (in the sense of the model-view-controller design pattern) to a file and get them back again.
  2. NSFetchedResultsController
    • The fetched results controller is used to efficiently manage the results returned from a Core Data fetch request to provide data for a UITableView object.
    • It can also be used to monitor changes to objects in the associated managed object context, and report changes in the results set to its delegate
    • It can cache the results of its computation
  3. UITableView object
    • Encapsulates the displaying and editing hierarchical lists of information

qzmedr5c
Sample To Demonstrate http://code.msdn.microsoft.com/wpapps/Model-View-ViewModel-Sample-8cb92fd9

vo2pyxmy
Tutorial On How To Implement -http://msdn.microsoft.com/en-us/library/gg521153.aspx

3n5phsbh
  1. Solution Explorer demonstrates the folder.
    • You can see the folders Model, View, ViewModel

3tugn044
  1. ObservableCollection
    • Represents a dynamic data collection that provides notifications when items get added, removed, or when the whole list is refreshed.
    • Similar to NSfetchedResultsController
    • Supports the INotifyPropertyChanged Interface, whick notifies clients that a property value has changed
  2. UserControl
    • User controls allow you to share some UI between your apps
    • Allows you to isolate parts of your UI into user controls and attempt to share those

Conclusion
  1. This post gives you the necessary knowledge to start utilizing the M-V-VM framework inherent in Windows Phone 8 and Windows 8 applications.
  2. There are likely some differences in implementation between iOS MVC and Windows Phone 8 M-V-VM, but certainly they are identical in concept and function.
  3. The testability and separation of concerns are some of the good things that come out of this particular pattern.
  4. Remember, MVC is more than just a framework. It’s a pattern that has been around since the late 1970s.
    1. It was created by Trygve Reenskaug at Xerox PARC, as part of the Smalltalk system.
  5. This pattern is used in many Microsoft frameworks and applications. It is well documented and developers familiar with the iOS MVC framework, should have a smooth path migrating their apps to the Windows world.

 

Published at DZone with permission of Bruno Terkaly, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)