Search code examples
codebasewindows-phone-8

Share code base for WP7 and WP8


I'm working on architecture of new business application targeting WP7 and WP8. For WP7 we will use silverlight app model and want to be prepared to reuse the code while moving to WP8 (we will want to use additional features on WP8).

Since WP8 will also support xaml and C# do you have any special recommendations how to organize app structure, select appropriate methodology.

To summarize recommendations below:

  1. Separate code and UI.
  2. For business logic you can use C# Windows Phone Class Library (7.1 to work for both WP7 and WP8)
  3. Consider using the Task Parallel Library for Windows Phone, if you do a lot of async.
  4. Use separate lib for WP8 specific features. Connect it to WP8 only.
  5. You may want to move common UI to separate lib since it should be supported in both Wp7 and Wp8 (according to my experiments).

Solution

  • how to organize app structure, select appropriate methodology.

    Well, MVVM is always a hit when working with Windows Phone. Any good clean structure, following SOLID principles will do just fine.

    Windows Phone 8 will support the new C# 5.0 language features, so if you have a lot of asynchronous code, consider using the Task Parallel Library for Windows Phone for Windows Phone 7, since all calls returning Task will support the new await operator in C# 5.0.

    The most important change in Windows Phone 8 is new, and better performing controls. If you want to support both platforms with the same code-base, you want to try separate your UI code as much as possible from the rest of the application. Most likely you'll want to separate UI logic, such as ViewModels, as well.

    Consider having at least one separate assembly for your business logic, that handles data query operations and/or calculations.

    As for new features, like C++ development / WinRT interop, that'll be done though separate assemblies, which you only can reference from your Windows Phone 8 assemblies anyway; which means it shouldn't provide any concerns for your current application structure.