Universal Win Apps: Shared Project vs Portable Class Library – Advantages and Disadvantages

 

With the introduction of Visual Studio 2013 and the unified Windows runtime, developers can now build apps that natively target both Windows 8.1 and Windows phone 8.1. There are two mechanism that enable this: Shared Project and Portable Class Library.

Sometimes it becomes necessary to make choices as to which one makes the most sense under certain requirements. Below are some things to know that will help you in making that decision.

SHARED PROJECT

Also known as Shared Folder allows for a structured approach to building universal Windows apps.

They have some advantages:

    • Shared Folder enable the use of platform-specific APIs through the use of  conditional compilation
    • Shared Folder also enable cases where the source is compatible, but the binary wouldn't be, as when APIs are in different namespaces.

And some disadvantages:

    • They require sharing either the source code or multiple binaries, and this places part of the complexity on the consumer of the code.
    • They require convention and discipline to centralize handling of divergent APIs so that the code doesn't become maintainable.

PORTABLE CLASS LIBRARY (PCL)

PCL has been improved to better support building universal Windows apps. this support goes from the WinRT to XAML controls to the VS Editor. Like Shared Project, it has advantages and disadvantages.

Advantages:

    • It offers an extremely simply deployment and sharing model
    • It scales well to large systems requiring multiple solutions, involving third parties or multiple programming languages

Disadvantages:

    • Relies heavily on the fact that the targets have converged APIs
    • Handling divergent APIs requires using higher-level abstracts, such as dependency injection or Inversion of Control containers.

The convergence of Windows 8 and Windows Phone 8 will lead to level of unification that will continue to simply the developer experience (productivity), and yield end-user experiences that would be hard, if not impossible, in the platform silo days.

Are you a Startup and interested in expanding your reach? drop me a note (joelrey@microsoft.com). Let’s talk about your business/technical goals and how you can tap into our capabilities for Startups.

STARTUPCITIZEN
@startupcitizen
www.facebook.com/startupcitizen