- 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.
- 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.
- 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.
- 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.
- 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.
- iOS leverages The Model-View-Controller (MVC) design pattern
- The pattern defines the roles objects play in the application
- Also defines the way objects communicate with each other
- Each object has roles
- There are 3 roles:
- 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
- Encapsulates application that users can see. Views draw themselves
- Gets updated by controller
- Tells controller about user action
- 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
- 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.
- 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
- UITableView object
- Encapsulates the displaying and editing hierarchical lists of information
- Solution Explorer demonstrates the folder.
- You can see the folders Model, View, ViewModel
- 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, which notifies clients that a property value has changed
- 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
- This post gives you the necessary knowledge to start utilizing the M-V-VM framework inherent in Windows Phone 8 and Windows 8 applications.
- 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.
- The testability and separation of concerns are some of the good things that come out of this particular pattern.
- Remember, MVC is more than just a framework. It’s a pattern that has been around since the late 1970s.
- It was created by Trygve Reenskaug at Xerox PARC, as part of the Smalltalk system.
- 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
, DZone MVB
Opinions expressed by DZone contributors are their own.