Question

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).
Was it helpful?

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.

OTHER TIPS

The current answers doesn't seem to go into detail on how the actual project structure might look like, so I thought I might share mine here:

What you can see below is the structure for my app which exists in 4 versions: (WP7,WP8)X(Pro,ad funded)

The code and the output folders (bin7, bin8,...) are placed in the first sub directory. The project files are placed in appropriately named subdirectories. The code files and assets are linked into the single projects. The files in the "Properties" folders are special to each version (other GUID, name, live tile icons etc). That way I have to hit once F6 and I have all XAPs for my current version. (Just have to collect them with a little script)

(FYI the "Pro" version is implemented with a #ifdef compiler flag.)

My WP7+WP8(+"PRO"-version) project structure

Silverlight is a framework based on C#, you are mixing languages and frameworks in your post, the only thing to consider is that WP7 only support C# 3.0 features, WP8 probably will be a more advanced workbench with DirectX and C# 4 or better, we don't know yet, but with WP8 also comes in the full support for C and C++.

Silverlight does not receive significant updates or news from a long time. If you really want to target this 2 OS i suggest to use a shared C# 3.0 codebase, avoiding the use of Silverlight as much as possible, and probably could be a better choice thinking to the fact that the WP7 devices are pratically dead in terms of updates and core features; they are Silverlight-based device with XNA for games, but some hardware related features are very low-end, plus Microsoft is not speaking about Silverlight for a long time and this new updates about the C/C++ support could be a game-changer for a developer.

Also there is C# 5.0 on the way, a WP7 is already old, it could be older in weeks, also i don't know the details of your project but you probably have to plan some months/weeks doing support and various fixes, i think that you probably should have a very good reason to start a C# 3.0 project targeting a WP7 platform, i'm not discussing WP7 as OS, i'm discussing the convenience of doing what you are planning considering the immediate future and the lack of support and news on some projects from Microsoft.

Stay in touch with the team in Microsoft that talks about this things https://twitter.com/#!/wpdev and see if you can get a much more detailed picture.

In the end keep in mind that probably the only one thing in common that worth considering is the support for the C# 3.0 language, the frameworks may vary or could be more convenient to adopt the new ones, also with C/C++ you get an infinite amount of new libraries for everything.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top