Reputation: 7102
I'm looking into porting an application to windows 8 metro. The main engine is a C++
library, so all I'm looking to do is create the GUI (then hook it to the C++
engine).
I want to know if creating a metro app, will I be able to use the same code and build it for desktop (windows 7, etc.)? If there is extra work how much?
Also in the future I will be looking into creating a windows 8 mobile app, would I be able to be able to share any metro GUI code or would it be best to start from scratch?
The project is a massive one so code reuse is a big positive.
Upvotes: 1
Views: 1271
Reputation: 23764
The UI layers for each platform are quite different; however, there are commonalities in how they are approached. For instance C#/VB/XAML can be used across Phone, Windows, Desktop, (and even web: Silverlight) but there are differences in specific features, supported properties, etc., making it difficult to just 'recompile'
Your best bet in my opinion is to adopt a pattern where the differences are isolated; MVVM is a great candidate for GUI applications across the platforms. It requires a different UI layer for each target - but you want that anyway to take advantage of form factor, user expectations, etc. In each case, the code could be C#/VB XAML though with perhaps a number of constructs and assets reused (even if via copy-and-paste). Behind the scenes the 'plumbing' might be exactly the same, whether it be an internal business object layer or web services in the cloud.
In terms of the backend, there are also platform differences, something that the Portable Class Library can help alleviate particularly for future efforts. Looking forward as well, announcements like the Windows 8 Shared Core certainly hold promise for making jobs like this easier.
There are a number of posts and guidance out there for reuse across platforms like WPF and Silverlight, and many of the themes will be similar, though the details may not be specific to your target platforms. Here's a few of them that may help you frame your approach, again don't focus on the use of "Silverlight" but rather on the techniques and concerns addressed in the articles.
Sharing Code Between Silverlight and WPF
Reusing your existing Silverlight components with Windows Phone 7
Upvotes: 2