Comparing Windows 8 and Windows Phone – Path to windows phone and windows 8 convergence (Part 1)

How can you make your apps in such a way that you can reuse your code for both the platforms.
After this blog, you should have a good understanding of:
-Major similarities and differences between windows phone 8 and windows 8
-How to build for both platforms with major code reuse

The blog doesn’t cover:
-Writing a windows phone 8 or windows 8 app and code that automatically runs on both platforms (impossible)

WINDOWS 8 PLATFORM:
I will focus mostly on c# in Windows store apps which is an easy overlap between wp8 and windows 8

Windows 8 platform

WINDOWS PHONE API

In the past, in windows phone (especially wp7), it was all about .NET, C# and VB. But eventually when we moved to windows phone 8, it included a runtime that additionally has C++ and finally the Direct3D, XAudio2, MF etc. are added which can be done in C++.

Windows Phone API

Comparing Windows 8 and windows phone 8:

FORM FACTORS:

WINDOWS PHONE 8

WINDOWS 8

Comes in 3 form factors (800×480, 1280×720, 1280×768)   Comes in many factors (1024×768(min) and more)
Can be used in portrait and landscape, but most apps are built to be   used in portrait. Can be used in portrait, landscape, snapped (smaller screen along left hand side), filled (remainder of screen when use snap view)
Screen size is small – <5 inch screen (as obviously it has to fit in pockets ;)) Has a larger screen size – 10 inch screens+ (as tiles scroll horizontally)

USER EXPERIENCE CONSIDERATIONS:

Windows Phone

Windows 8

It is mostly in portrait view   and is used with one handed touch for scrolling and typing Windows 8 as a tablet is meant   to be held with 2 hands.
Guarantee of specific hardware   like camera, accelerometer etc. No guarantee of specific   hardware (have to check whether a specific feature is available on the device the app is installed on)
Due to small screen size,   multiple columns of content should be avoided (scroll up/down for more   content) Can have more columns of content   because of organized screen and larger screen size (scroll left/right for   more content)
Limited room for options on app   bar Significantly more room for options on 2 app bars (on top and bottom)
Guarantee hardware back button No hardware back button but an onscreen back button available
No semantic zoom Semantic zoom available

XAML NAMESPACE AND CONTROLS:
There is a huge overlap between controls on both platforms. Many of the controls are same, many of them are separate in both platforms and there are many controls that are present in both platforms but in different namespaces:

  • Windows.XAML.UI.Controls contains Windows 8 controls
  • Microsoft.Phone.Controls and Microsoft.Phone.Shell contain Windows Phone 8 controls.
  • An example:
    • Windows.XAML.UI.Controls.Canvas (Windows 8)
    • System.Windows.Controls.Canvas (Windows Phone 8
  • Unsupported controls on the other platform:
    • For example <pivot></pivot> – specifically designed for windows phone so it is not supported by windows 8

Some examples of controls in different namespaces are:

Windwos Phone 8

Windows 8

PhoneApplicationPage is the root element Page is the root element
LongListSelector used to show vertically scrolling content ListView to show vertically scrolling content
Pivot control is used to page content horizontally FlipView control is used to page control horizontally
ApplicationBar control is used AppBar control is used
                        ———— GridView is used to group content in a grid

DATA MODEL AND SUPPORTING CODE:

Because only developers can clearly understand the code, hence the user interface should be separated and not included in the code in data model. Data model makes the project organized and portable to be reused on other platforms. So, data should always be put in data model to reuse and leverage the APIs that are portable between the two platforms.

LOCAL STORAGE:

  • Both platforms support storage of key/value pairs. It uses isolated storage to keep any app isolated from another app on that platform (for security and isolation purpose).
  • WP8 supports SQL CE while Windows 8 has no built in Microsoft SQL database but it has other SQLite Libraries available that can be downloaded and used.
  • Both platforms have a shared API in Windows.Storage namespace.
  • WP8 APIs are a subset of the full APIs, hence, not all of Windows 8 APIs are available on WP8. E.g. No roaming data store, temporary data store, local settings, roaming settings

APPLICATION LIFECYCLE:

Different app lifecycle for windows phone and Windows 8

application lifecycle

On both platforms:

  • CPU resources are consumed only by any foreground app.
  • In windows, any other apps become suspended and in windows phone they are deactivated.
  • On suspension/deactivation, background tasks are stopped to save the app state for which app is given time by both platforms.

There are certain events to be kept in mind:

Windows Phone 8:

Windows 8:

Derived from:   System.Windows.Application Derived from: Windows.UI.XAML.Application
Application_Launching OnLaunched
Application_Activated OnSuspending
Application_Deactivated
Application_Closing

That’s for now. Other similarities and differences will be covered in part 2. This is my first blog so do give your feedback.

Leave a comment