SlideShare a Scribd company logo
SOLID programming with 
portable class libraries 
Vagif Abilov
About myself 
• Mail: vagif.abilov@gmail.com 
• Twitter: @ooobject 
• GitHub: object 
• BitBucket: object 
• Blog: http://bloggingabout.net/blogs/vagif/default.aspx 
• Some articles: http://www.codeproject.com 
• Some open source projects: 
– Simple.Data OData adapter 
– Simple.OData.Client 
– MongOData 
– PCL Conformance Analyzer
Poll: do you care about PCL? 
• Are you familiar with the concept of PCL? 
• Have you used portable class libraries? 
• Have you built your own portable class libraries? 
• Do you maintain source code for applications that need 
to be deployed on multiple platforms?
By the way, what is «portability»? 
According to Wikipedia: 
Portability in high-level computer programming is the 
usability of the same software in different environments. 
Strategies for portability 
• Transferring installed program files to another computer of basically 
the same architecture. 
• Reinstalling a program from distribution files on another computer of 
basically the same architecture. 
• Building executable programs for different platforms from source 
code; this is what is usually understood by "porting".
Portabilitity definition (cont’d) 
Achieving portability between different processors, 
according to Wikipedia: 
• Non-web programs, installed upon a computer in the 
normal manner, can have more control, and yet achieve 
system portability by linking to the Java package. 
• Software can be recompiled and linked from source 
code for different operating systems and processors if 
written in a programming language supporting 
compilation for the platforms.
Innovative portability strategies 
• Xamarin products: compiling to native apps 
– Binding Objective-C libraries (iOS) 
– Binding Java libraries (Android) 
• Portable class libraries: managed assemblies that work 
on more than one .NET Framework platform 
– .NET 4.0, 4.0.3, 4.5 
– Silverlight 4, 5 
– Windows Phone 7, 7.5, 8 
– .NET for Windows Store applications 
– Xbox 360
Recompilation vs. binary reuse 
Does it really matter if we package code in 
reusable assemblies? Can we compile our 
code for a new target platform when we 
actually need it?
PCL advantages 
• If the code is not bound to a specific platform, then 
packaging it in a portable class library will guard it from 
unintended platform dependencies by enforcing 
portability constraints at early development stage 
• Packaging code as PCL may require introduction of 
higher level abstractions, extraction of interfaces, 
inversion of dependencies and provide guidance to 
follow SOLID principles
Platform support in PCL
Authoring portable class libraries
Case study 
From 
Simple.Data OData adapter 
to 
Simple.OData.Client PCL
What is Simple.Data 
• A lightweight, dynamic data access component for 
.NET 
• Written and maintained by Mark Rendle 
• Adapters for SQL Server, Oracle, Sqlite, MongoDB, 
OData, Oracle, PostgreSql, Informix 
• An alternative to ORM libraries, such as Entity 
Framework and NHibernate
Simple.Data code example 
var db = Database.Open(); 
var titles = db.Albums 
.All() 
.Select(db.Albums.Title) 
.Where(db.Albums.GenreId == 1 && 
db.Albums.AlbumId > 400);
Simple.Data OData adapter 
• An alternative to WCF DataServices client 
• Better fits RESTful nature of OData protocol than SOAP 
alike client code generation triggered with «Add Service 
Reference»
Simple.Data.OData code example 
var db = Database.Opener.Open( 
"http://packages.nuget.org/v1/FeedService.svc/"); 
var package1 = db.Packages 
.FindByTitle("Simple.Data.OData"); 
var package2 = db.Packages 
.Find(db.Packages.Title == "Simple.OData.Client"); 
Generate HTTP GET request URLs: 
Packages?$filter=Title+eq+%27Simple.Data.OData%27 
Packages?$filter=Title+eq+%27Simple.OData.Client%27
Adapter 
• Structural design pattern 
• Converts the interface of a class into another interface 
clients expect 
Common API 
Adapter 
External service
Simple.Data OData version <= 0.5 
Simple.Data API 
Simple.Data OData Adapter 
OData protocol
ODataPad
Making the adapter portable 
• An adapter can target new platforms as long as it 
provides a bridge between interfaces (and interfaces 
don’t refer to types bound to specific platforms) 
• OData protocol is platform agnostic 
• Most of OData adapter code deals with either parsing 
XML documents returned by an OData service or 
formatting CLR objects as XML documents to send to 
OData service 
• Simple.Data API uses types defined in Simple.Data 
library 
• Simple.Data supports Mono (hope of portability with 
other platforms)
Targeting Windows Store apps
System.Data namespace 
• Microsoft.SqlServer.Server 
• System.Configuration 
• System.Data 
• System.Data.Common 
• System.Data.Odbc 
• System.Data.OleDb 
• System.Data.Sql 
• System.Data.SqlClient 
• System.Data.SqlTypes 
• System.Xml
PCL Conformance Analyzer 
Demo
Simple.Data.OData version >= 0.6 
Simple.Data API 
Simple.Data OData Adapter 
Simple.OData.Client PCL 
OData protocol
Simple.OData.Client 
• Version 0.13 
– .NET 4.0, .NET 4.0.3, 4.5 
– Windows Store 
– Silverlight 5 
– Windows Phone 8 
• Version 0.17 
– Xamarin.Android 
– Xamarin.iOS
But what about SOLID principles? 
Example 
Adding support for authentication
User request: support authentication 
• First implementation: accept user credentials (user + 
password), create authentication object using one of 
supported schemes (Basic, Windows etc.) 
• Worked like a charm, easy to use in client code 
var odataFeed = new ODataFeed( 
"http://www.myservice.com/api", 
"Vagif", 
"Password123"); 
• At that time Simple.Data OData adapter included non-portable 
version of Simple.OData.Client
ODataFeed 
public class ODataFeed 
{ 
public string Url { get; set; } 
public string User { get; set; } 
public string Password { get; set; } 
public string Domain { get; set; } 
public bool IntegratedSecurity { get; set; } 
}
Creating Web request 
var request = (HttpWebRequest)WebRequest.Create(uri); 
if (this.Credentials.IntegratedSecurity) 
{ 
request.Credentials = CredentialCache.DefaultNetworkCredentials; 
} 
else if (!string.IsNullOrEmpty(this.Credentials.User)) 
{ 
request.Credentials = new NetworkCredential( 
this.Credentials.User, 
this.Credentials.Password, 
this.Credentials.Domain); 
}
Merging with Portable branch 
Project doesn’t compile! 
• System.Net.CredentialCache: .NET 4.x only 
• System.Net.NetworkCredential: most of platforms
What went wrong? 
• Simple.Data OData adapter took responsibility to create 
user credentials based on sensitive user information 
• Leaving aside security aspects, the adapter violated 
single responsibility principle 
• The adapter restricted supported authentication metods 
to those provided by credential creation code 
• The adapter is not open to extending it with new 
authentication methods, so it violated open/closed 
principle too 
• Use of interface segregation principle would avoid this 
mistake 
• PCL compliance forced use of interfaces
Revised implementation 
In platform-spefic client code 
var odataFeed = new ODataFeed( 
"http://www.myservice.com/api", 
credentials); 
In Simple.OData.Client PCL 
var request = (HttpWebRequest)WebRequest.Create(uri); 
request.Credentials = this.Credentials;
Revised implementation 
• Credentials is an instance of a class that implements 
System.Net.ICredentials interface 
• Neither Simple.Data OData adapter (.NET 4.x) nor 
Simple.OData.Client refer to a specific authentication 
scheme 
• All present and future authentication schemes are 
supported as long as they conform ICredentials
Observations 
• Some SOLID principles require coding discipline and 
leave a room for interpretation, IMHO especially SRP 
and OCP (John Skeet on OCP: «While I've obviously considered the 
possibility that I'm the only one who finds it confusing, I've heard enough variation in 
the explanations of it to suggest that I'm really not the only one») 
• PCL conformance requirement doesn’t release you 
from the responsibility to make the design decision, but 
it can guard you from making obvious mistakes and 
sometimes even guide you in a right direction 
• PCLs make you more carefully plan service 
instantiation and use of non-functional utilities (logging, 
instrumentation etc.)
PCLs and concrete classes 
• Portable class libraries do not push the work of 
implementing platform-specific services to client 
applications 
• PCLs can be packaged as a single portable deployment 
unit 
– Autofac 
– Json.NET 
– Simple.OData.Client 
• PCLs can also be compound, consisting of core 
portable and platform-specific parts 
– MetroLog 
– Splat
MetroLog architecture
MetroLog NuGet specification 
<files> 
<file src="MetroLog.dll" target="libportable-net45+ 
wp8+win8MetroLog.dll" /> 
<file src="MetroLog.dll" target="libnet45MetroLog.dll" /> 
<file src="MetroLog.NetFx.dll" target="libnet45MetroLog.NetFx.dll" /> 
<file src="MetroLog.dll" target="libnetcore45MetroLog.dll" /> 
<file src="MetroLog.NetCore.dll" 
target="libnetcore45MetroLog.NetCore.dll" /> 
</files>
PCLs consuming PCLs 
• A PCL client can also be a portable library 
• Client target platforms must be a subset of the 
referenced PCL’s target platforms 
• Functionality that requires platform-specific services is 
usually referred using interfaces and abstract classes 
• There is a trick to use concrete platform-specific 
classes in client PCLs by placing in the referenced PCL 
a dummy class with the same API surface and 
assembly identity as the platform-specific class
PCL profiles and portable subsets 
• Profile is a set of supported platforms 
• Portable subset is a family of profiles that expose 
certain version of .NET FX API surface area 
– Profile 78: Portable Subset: 
• .NET 4.5 
• Windows Phone 8 
• Windows Store 
– Profile 95: Portable Subset (Legacy): 
• .NET 4.0.3 and higher 
• Silverlight 4 and higher 
• Windows Phone 7 and higher 
• Windows Store
PCLs for Android and iOS 
Demo: Xamarin .NET Mobility Scanner 
Example: Reflection API portability
Polyglot programming with PCLs 
• Use right language to solve specific problems 
• C# provides the best ‘one size fits all’ choice 
• F# is very efficient for immutable data transformations, 
financial computations, machine learning 
• F# code can be packaged in a PCL and shared among 
different platforms (inluding Android and iOS!) 
– No official support to target Windows Phone 8 using F# PCL, but there 
is a workaround 
– Both PCL and F# support in Xamarin are work in progress (with 
changes being made literally while I am speaking now) 
• Core logic can be written in C# and F# and packaged 
as PCL, and UI is added using platform-specific tools
PCLs for the future 
• Profiles for v.4.0 API surface are being deprecated 
• Visual Studio 2013 can open PCLs that target legacy 
platforms, but it will upgrade Silverlight to target version 
5 and Windows Phone to target version 8 
• Xamarin PCLs targets both v.4.0 and v.4.5 API surfaces 
• If a library target wide range of platforms (both 4.0 and 
4.5), its NuGet package should include separate binaries 
for each surface 
• Consider only targeting v.4.5 API surface for new 
projects unless you need to support legacy platforms
Using PCLs in UI 
• Use of portable class libraries can result in significant 
code reuse in cross-platform application development 
• Most popular approach to cross-platform UI with PCLs 
is to use MVVM pattern and package core services, 
models and view models in a portable library 
• Most popular MVVM frameworks that have PCLs are 
MvvmLights and MvvmCross 
• MvvmCross supports targeting Xamarin.iOS and 
Xamarin.Android (and provides phenomenal support at 
StackOverflow by @slodge)
Example: Lions Roar 
• Developed by Sequence Agency 
• UI is built using MvvmCross 
• View models PCL (2463 LOC) 
• Entities PCL (691 LOC) 
• Supported plalforms 
– Windows Store (1166 LOC) 
– Windows Phone 8 (668) 
– Android Phone/Tablet (1172) 
– iPhone/iPad (2000 LOC)
Using PCL in ODataPad UI 
• ODataPad views show images 
• Original view model design included core portable base 
view model (without image data) and platform-specific 
view models (with image data) 
• Small picture size makes possible storing images in 
base64 format and reuse a single view model in all 
platforms 
• Rendering images requires platform-specific value 
converters 
• A PCL with a design-time view model serves design 
data to all Visual Studio designers (Blend)
Conclusion 
• Portable class libraries are not only for binary reuse 
• Packaging code as PCLs helps making code cleaner: 
– Extract interfaces 
– Unify platform-specific services 
– Inject service dependencies 
– Use portable data structures 
• Consider PCLs when choosing third party libraries 
– Ready for other platforms 
– Indication of a proper design 
– May only have dependencies to other portable libraries 
• Consider make your next library portable even if you 
only target a single platform!
Resources 
• Daniel Plaisted «How to Make Portable Class Libraries 
Work for You» 
• Scott Hanselman «Cross-Platform Portable Class 
Libraries with .NET are Happening» 
Open source projects at GitHub: 
• AutoFac 
• MetroLog 
• Splat 
• MvvmCross 
• Simple.OData.Client
Thank you! 
• Mail: vagif.abilov@gmail.com 
• Twitter: @ooobject 
• GitHub: object 
• BitBucket: object 
• Blog: http://bloggingabout.net/blogs/vagif/default.aspx 
The source code for this PCL Conformance Analyzer can 
be found at https://github.com/object/PclAnalyzer

More Related Content

What's hot

Software job options
Software job optionsSoftware job options
Software job options
Mohit Kanwar
 
Integrating Alfresco with Portals
Integrating Alfresco with PortalsIntegrating Alfresco with Portals
Integrating Alfresco with Portals
Piergiorgio Lucidi
 
Enterprise Java Web Application Frameworks Sample Stack Implementation
Enterprise Java Web Application Frameworks   Sample Stack ImplementationEnterprise Java Web Application Frameworks   Sample Stack Implementation
Enterprise Java Web Application Frameworks Sample Stack ImplementationMert Çalışkan
 
EJB 3.2 - Java EE 7 - Java One Hyderabad 2012
EJB 3.2 - Java EE 7 - Java One Hyderabad 2012EJB 3.2 - Java EE 7 - Java One Hyderabad 2012
EJB 3.2 - Java EE 7 - Java One Hyderabad 2012
Jagadish Prasath
 
WebLogic and GraalVM
WebLogic and GraalVMWebLogic and GraalVM
WebLogic and GraalVM
Michel Schildmeijer
 
Dirigible powered by Orion for Cloud Development (EclipseCon EU 2015)
Dirigible powered by Orion for Cloud Development (EclipseCon EU 2015)Dirigible powered by Orion for Cloud Development (EclipseCon EU 2015)
Dirigible powered by Orion for Cloud Development (EclipseCon EU 2015)
Nedelcho Delchev
 
Net framework
Net frameworkNet framework
Net framework
Mahfuz1061
 
Take a Groovy REST
Take a Groovy RESTTake a Groovy REST
Take a Groovy REST
Restlet
 
Spring
SpringSpring
Spring
Suman Behara
 
Ekon21 Microservices - SOLID Meets SOA
Ekon21 Microservices - SOLID Meets SOAEkon21 Microservices - SOLID Meets SOA
Ekon21 Microservices - SOLID Meets SOA
Arnaud Bouchez
 
What's New and Next in OpenNTF Domino API (ICON UK 2014)
What's New and Next in OpenNTF Domino API (ICON UK 2014)What's New and Next in OpenNTF Domino API (ICON UK 2014)
What's New and Next in OpenNTF Domino API (ICON UK 2014)
Paul Withers
 
2.3 (Architecture) Moving to Managed Code
2.3   (Architecture) Moving to Managed Code2.3   (Architecture) Moving to Managed Code
2.3 (Architecture) Moving to Managed CodeMicro Focus
 
ASP.NET 01 - Introduction
ASP.NET 01 - IntroductionASP.NET 01 - Introduction
ASP.NET 01 - Introduction
Randy Connolly
 
.Net programming with C#
.Net programming with C#.Net programming with C#
.Net programming with C#
NguynSang29
 
Modern web application development with java ee 7
Modern web application development with java ee 7Modern web application development with java ee 7
Modern web application development with java ee 7
Shekhar Gulati
 

What's hot (15)

Software job options
Software job optionsSoftware job options
Software job options
 
Integrating Alfresco with Portals
Integrating Alfresco with PortalsIntegrating Alfresco with Portals
Integrating Alfresco with Portals
 
Enterprise Java Web Application Frameworks Sample Stack Implementation
Enterprise Java Web Application Frameworks   Sample Stack ImplementationEnterprise Java Web Application Frameworks   Sample Stack Implementation
Enterprise Java Web Application Frameworks Sample Stack Implementation
 
EJB 3.2 - Java EE 7 - Java One Hyderabad 2012
EJB 3.2 - Java EE 7 - Java One Hyderabad 2012EJB 3.2 - Java EE 7 - Java One Hyderabad 2012
EJB 3.2 - Java EE 7 - Java One Hyderabad 2012
 
WebLogic and GraalVM
WebLogic and GraalVMWebLogic and GraalVM
WebLogic and GraalVM
 
Dirigible powered by Orion for Cloud Development (EclipseCon EU 2015)
Dirigible powered by Orion for Cloud Development (EclipseCon EU 2015)Dirigible powered by Orion for Cloud Development (EclipseCon EU 2015)
Dirigible powered by Orion for Cloud Development (EclipseCon EU 2015)
 
Net framework
Net frameworkNet framework
Net framework
 
Take a Groovy REST
Take a Groovy RESTTake a Groovy REST
Take a Groovy REST
 
Spring
SpringSpring
Spring
 
Ekon21 Microservices - SOLID Meets SOA
Ekon21 Microservices - SOLID Meets SOAEkon21 Microservices - SOLID Meets SOA
Ekon21 Microservices - SOLID Meets SOA
 
What's New and Next in OpenNTF Domino API (ICON UK 2014)
What's New and Next in OpenNTF Domino API (ICON UK 2014)What's New and Next in OpenNTF Domino API (ICON UK 2014)
What's New and Next in OpenNTF Domino API (ICON UK 2014)
 
2.3 (Architecture) Moving to Managed Code
2.3   (Architecture) Moving to Managed Code2.3   (Architecture) Moving to Managed Code
2.3 (Architecture) Moving to Managed Code
 
ASP.NET 01 - Introduction
ASP.NET 01 - IntroductionASP.NET 01 - Introduction
ASP.NET 01 - Introduction
 
.Net programming with C#
.Net programming with C#.Net programming with C#
.Net programming with C#
 
Modern web application development with java ee 7
Modern web application development with java ee 7Modern web application development with java ee 7
Modern web application development with java ee 7
 

Viewers also liked

Cross-platform Mobile Development using Portable Class Libraries
Cross-platform Mobile Development using Portable Class LibrariesCross-platform Mobile Development using Portable Class Libraries
Cross-platform Mobile Development using Portable Class Libraries
Vagif Abilov
 
F# in Action: Playing Functional Conway's Game of Life
F# in Action: Playing Functional Conway's Game of LifeF# in Action: Playing Functional Conway's Game of Life
F# in Action: Playing Functional Conway's Game of Life
Vagif Abilov
 
А нам-то зачем функциональное программирование?
А нам-то зачем функциональное программирование?А нам-то зачем функциональное программирование?
А нам-то зачем функциональное программирование?
Vagif Abilov
 
Staying Close to Experts with Executable Specifications
Staying Close to Experts with Executable SpecificationsStaying Close to Experts with Executable Specifications
Staying Close to Experts with Executable Specifications
Vagif Abilov
 
iSeries Modernization: RPG/400 to Java Migration
iSeries Modernization: RPG/400 to Java MigrationiSeries Modernization: RPG/400 to Java Migration
iSeries Modernization: RPG/400 to Java Migration
ecubemarketing
 
Unificacion Alemana
Unificacion AlemanaUnificacion Alemana
Unificacion Alemana
Viviana Segura
 

Viewers also liked (6)

Cross-platform Mobile Development using Portable Class Libraries
Cross-platform Mobile Development using Portable Class LibrariesCross-platform Mobile Development using Portable Class Libraries
Cross-platform Mobile Development using Portable Class Libraries
 
F# in Action: Playing Functional Conway's Game of Life
F# in Action: Playing Functional Conway's Game of LifeF# in Action: Playing Functional Conway's Game of Life
F# in Action: Playing Functional Conway's Game of Life
 
А нам-то зачем функциональное программирование?
А нам-то зачем функциональное программирование?А нам-то зачем функциональное программирование?
А нам-то зачем функциональное программирование?
 
Staying Close to Experts with Executable Specifications
Staying Close to Experts with Executable SpecificationsStaying Close to Experts with Executable Specifications
Staying Close to Experts with Executable Specifications
 
iSeries Modernization: RPG/400 to Java Migration
iSeries Modernization: RPG/400 to Java MigrationiSeries Modernization: RPG/400 to Java Migration
iSeries Modernization: RPG/400 to Java Migration
 
Unificacion Alemana
Unificacion AlemanaUnificacion Alemana
Unificacion Alemana
 

Similar to SOLID Programming with Portable Class Libraries

MVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming modelMVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming model
Alex Thissen
 
.NET Cloud-Native Bootcamp
.NET Cloud-Native Bootcamp.NET Cloud-Native Bootcamp
.NET Cloud-Native Bootcamp
VMware Tanzu
 
Service fabric and azure service fabric mesh
Service fabric and azure service fabric meshService fabric and azure service fabric mesh
Service fabric and azure service fabric mesh
Mikkel Mørk Hegnhøj
 
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Anupam Ranku
 
Asp.Net Core MVC , Razor page , Entity Framework Core
Asp.Net Core MVC , Razor page , Entity Framework CoreAsp.Net Core MVC , Razor page , Entity Framework Core
Asp.Net Core MVC , Razor page , Entity Framework Core
mohamed elshafey
 
ASP.NET vNext
ASP.NET vNextASP.NET vNext
ASP.NET vNext
Alex Thissen
 
{code} and containers
{code} and containers{code} and containers
{code} and containers
{code} by Dell EMC
 
.NET Cloud-Native Bootcamp- Los Angeles
.NET Cloud-Native Bootcamp- Los Angeles.NET Cloud-Native Bootcamp- Los Angeles
.NET Cloud-Native Bootcamp- Los Angeles
VMware Tanzu
 
Current & Future Use-Cases of OpenDaylight
Current & Future Use-Cases of OpenDaylightCurrent & Future Use-Cases of OpenDaylight
Current & Future Use-Cases of OpenDaylight
abhijit2511
 
Introduction to ASP.NET 5
Introduction to ASP.NET 5Introduction to ASP.NET 5
Introduction to ASP.NET 5
mbaric
 
Apache Cordova 4.x
Apache Cordova 4.xApache Cordova 4.x
Apache Cordova 4.x
Ivano Malavolta
 
Unboxing ASP.NET Core
Unboxing ASP.NET CoreUnboxing ASP.NET Core
Unboxing ASP.NET Core
Kevin Leung
 
ITB2017 - Keynote
ITB2017 - KeynoteITB2017 - Keynote
ITB2017 - Keynote
Ortus Solutions, Corp
 
Dot net Online Training | .Net Training and Placement online
Dot net Online Training | .Net Training and Placement onlineDot net Online Training | .Net Training and Placement online
Dot net Online Training | .Net Training and Placement online
Garuda Trainings
 
{code} and Containers - Open Source Infrastructure within Dell Technologies
{code} and Containers - Open Source Infrastructure within Dell Technologies{code} and Containers - Open Source Infrastructure within Dell Technologies
{code} and Containers - Open Source Infrastructure within Dell Technologies
The {code} Team
 
Building RESTfull Data Services with WebAPI
Building RESTfull Data Services with WebAPIBuilding RESTfull Data Services with WebAPI
Building RESTfull Data Services with WebAPI
Gert Drapers
 
How AD has been re-engineered to extend to the cloud
How AD has been re-engineered to extend to the cloudHow AD has been re-engineered to extend to the cloud
How AD has been re-engineered to extend to the cloudLDAPCon
 
.NET Core: a new .NET Platform
.NET Core: a new .NET Platform.NET Core: a new .NET Platform
.NET Core: a new .NET Platform
Alex Thissen
 
Open shift and docker - october,2014
Open shift and docker - october,2014Open shift and docker - october,2014
Open shift and docker - october,2014
Hojoong Kim
 

Similar to SOLID Programming with Portable Class Libraries (20)

MVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming modelMVC 6 - the new unified Web programming model
MVC 6 - the new unified Web programming model
 
.NET Cloud-Native Bootcamp
.NET Cloud-Native Bootcamp.NET Cloud-Native Bootcamp
.NET Cloud-Native Bootcamp
 
Service fabric and azure service fabric mesh
Service fabric and azure service fabric meshService fabric and azure service fabric mesh
Service fabric and azure service fabric mesh
 
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
Office 365 Saturday (Sydney) - SharePoint framework – build integrated user e...
 
Asp.Net Core MVC , Razor page , Entity Framework Core
Asp.Net Core MVC , Razor page , Entity Framework CoreAsp.Net Core MVC , Razor page , Entity Framework Core
Asp.Net Core MVC , Razor page , Entity Framework Core
 
ASP.NET vNext
ASP.NET vNextASP.NET vNext
ASP.NET vNext
 
{code} and containers
{code} and containers{code} and containers
{code} and containers
 
.NET Cloud-Native Bootcamp- Los Angeles
.NET Cloud-Native Bootcamp- Los Angeles.NET Cloud-Native Bootcamp- Los Angeles
.NET Cloud-Native Bootcamp- Los Angeles
 
Current & Future Use-Cases of OpenDaylight
Current & Future Use-Cases of OpenDaylightCurrent & Future Use-Cases of OpenDaylight
Current & Future Use-Cases of OpenDaylight
 
Introduction to ASP.NET 5
Introduction to ASP.NET 5Introduction to ASP.NET 5
Introduction to ASP.NET 5
 
Apache Cordova 4.x
Apache Cordova 4.xApache Cordova 4.x
Apache Cordova 4.x
 
Unboxing ASP.NET Core
Unboxing ASP.NET CoreUnboxing ASP.NET Core
Unboxing ASP.NET Core
 
ITB2017 - Keynote
ITB2017 - KeynoteITB2017 - Keynote
ITB2017 - Keynote
 
OpenStack Summit
OpenStack SummitOpenStack Summit
OpenStack Summit
 
Dot net Online Training | .Net Training and Placement online
Dot net Online Training | .Net Training and Placement onlineDot net Online Training | .Net Training and Placement online
Dot net Online Training | .Net Training and Placement online
 
{code} and Containers - Open Source Infrastructure within Dell Technologies
{code} and Containers - Open Source Infrastructure within Dell Technologies{code} and Containers - Open Source Infrastructure within Dell Technologies
{code} and Containers - Open Source Infrastructure within Dell Technologies
 
Building RESTfull Data Services with WebAPI
Building RESTfull Data Services with WebAPIBuilding RESTfull Data Services with WebAPI
Building RESTfull Data Services with WebAPI
 
How AD has been re-engineered to extend to the cloud
How AD has been re-engineered to extend to the cloudHow AD has been re-engineered to extend to the cloud
How AD has been re-engineered to extend to the cloud
 
.NET Core: a new .NET Platform
.NET Core: a new .NET Platform.NET Core: a new .NET Platform
.NET Core: a new .NET Platform
 
Open shift and docker - october,2014
Open shift and docker - october,2014Open shift and docker - october,2014
Open shift and docker - october,2014
 

Recently uploaded

Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
abdulrafaychaudhry
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
Jelle | Nordend
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
MayankTawar1
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
Paco van Beckhoven
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
AMB-Review
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
KrzysztofKkol1
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Shahin Sheidaei
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
Peter Caitens
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
XfilesPro
 
Why React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdfWhy React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdf
ayushiqss
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Hivelance Technology
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Globus
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 

Recently uploaded (20)

Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
Lecture 1 Introduction to games development
Lecture 1 Introduction to games developmentLecture 1 Introduction to games development
Lecture 1 Introduction to games development
 
De mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FMEDe mooiste recreatieve routes ontdekken met RouteYou en FME
De mooiste recreatieve routes ontdekken met RouteYou en FME
 
Software Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdfSoftware Testing Exam imp Ques Notes.pdf
Software Testing Exam imp Ques Notes.pdf
 
Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024Cracking the code review at SpringIO 2024
Cracking the code review at SpringIO 2024
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdfDominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
Dominate Social Media with TubeTrivia AI’s Addictive Quiz Videos.pdf
 
Designing for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web ServicesDesigning for Privacy in Amazon Web Services
Designing for Privacy in Amazon Web Services
 
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
Gamify Your Mind; The Secret Sauce to Delivering Success, Continuously Improv...
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, BetterWebinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
Webinar: Salesforce Document Management 2.0 - Smarter, Faster, Better
 
Why React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdfWhy React Native as a Strategic Advantage for Startup Innovation.pdf
Why React Native as a Strategic Advantage for Startup Innovation.pdf
 
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
Multiple Your Crypto Portfolio with the Innovative Features of Advanced Crypt...
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...Developing Distributed High-performance Computing Capabilities of an Open Sci...
Developing Distributed High-performance Computing Capabilities of an Open Sci...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 

SOLID Programming with Portable Class Libraries

  • 1. SOLID programming with portable class libraries Vagif Abilov
  • 2. About myself • Mail: vagif.abilov@gmail.com • Twitter: @ooobject • GitHub: object • BitBucket: object • Blog: http://bloggingabout.net/blogs/vagif/default.aspx • Some articles: http://www.codeproject.com • Some open source projects: – Simple.Data OData adapter – Simple.OData.Client – MongOData – PCL Conformance Analyzer
  • 3. Poll: do you care about PCL? • Are you familiar with the concept of PCL? • Have you used portable class libraries? • Have you built your own portable class libraries? • Do you maintain source code for applications that need to be deployed on multiple platforms?
  • 4. By the way, what is «portability»? According to Wikipedia: Portability in high-level computer programming is the usability of the same software in different environments. Strategies for portability • Transferring installed program files to another computer of basically the same architecture. • Reinstalling a program from distribution files on another computer of basically the same architecture. • Building executable programs for different platforms from source code; this is what is usually understood by "porting".
  • 5. Portabilitity definition (cont’d) Achieving portability between different processors, according to Wikipedia: • Non-web programs, installed upon a computer in the normal manner, can have more control, and yet achieve system portability by linking to the Java package. • Software can be recompiled and linked from source code for different operating systems and processors if written in a programming language supporting compilation for the platforms.
  • 6. Innovative portability strategies • Xamarin products: compiling to native apps – Binding Objective-C libraries (iOS) – Binding Java libraries (Android) • Portable class libraries: managed assemblies that work on more than one .NET Framework platform – .NET 4.0, 4.0.3, 4.5 – Silverlight 4, 5 – Windows Phone 7, 7.5, 8 – .NET for Windows Store applications – Xbox 360
  • 7. Recompilation vs. binary reuse Does it really matter if we package code in reusable assemblies? Can we compile our code for a new target platform when we actually need it?
  • 8. PCL advantages • If the code is not bound to a specific platform, then packaging it in a portable class library will guard it from unintended platform dependencies by enforcing portability constraints at early development stage • Packaging code as PCL may require introduction of higher level abstractions, extraction of interfaces, inversion of dependencies and provide guidance to follow SOLID principles
  • 11. Case study From Simple.Data OData adapter to Simple.OData.Client PCL
  • 12. What is Simple.Data • A lightweight, dynamic data access component for .NET • Written and maintained by Mark Rendle • Adapters for SQL Server, Oracle, Sqlite, MongoDB, OData, Oracle, PostgreSql, Informix • An alternative to ORM libraries, such as Entity Framework and NHibernate
  • 13. Simple.Data code example var db = Database.Open(); var titles = db.Albums .All() .Select(db.Albums.Title) .Where(db.Albums.GenreId == 1 && db.Albums.AlbumId > 400);
  • 14. Simple.Data OData adapter • An alternative to WCF DataServices client • Better fits RESTful nature of OData protocol than SOAP alike client code generation triggered with «Add Service Reference»
  • 15. Simple.Data.OData code example var db = Database.Opener.Open( "http://packages.nuget.org/v1/FeedService.svc/"); var package1 = db.Packages .FindByTitle("Simple.Data.OData"); var package2 = db.Packages .Find(db.Packages.Title == "Simple.OData.Client"); Generate HTTP GET request URLs: Packages?$filter=Title+eq+%27Simple.Data.OData%27 Packages?$filter=Title+eq+%27Simple.OData.Client%27
  • 16. Adapter • Structural design pattern • Converts the interface of a class into another interface clients expect Common API Adapter External service
  • 17. Simple.Data OData version <= 0.5 Simple.Data API Simple.Data OData Adapter OData protocol
  • 19. Making the adapter portable • An adapter can target new platforms as long as it provides a bridge between interfaces (and interfaces don’t refer to types bound to specific platforms) • OData protocol is platform agnostic • Most of OData adapter code deals with either parsing XML documents returned by an OData service or formatting CLR objects as XML documents to send to OData service • Simple.Data API uses types defined in Simple.Data library • Simple.Data supports Mono (hope of portability with other platforms)
  • 21. System.Data namespace • Microsoft.SqlServer.Server • System.Configuration • System.Data • System.Data.Common • System.Data.Odbc • System.Data.OleDb • System.Data.Sql • System.Data.SqlClient • System.Data.SqlTypes • System.Xml
  • 23. Simple.Data.OData version >= 0.6 Simple.Data API Simple.Data OData Adapter Simple.OData.Client PCL OData protocol
  • 24. Simple.OData.Client • Version 0.13 – .NET 4.0, .NET 4.0.3, 4.5 – Windows Store – Silverlight 5 – Windows Phone 8 • Version 0.17 – Xamarin.Android – Xamarin.iOS
  • 25. But what about SOLID principles? Example Adding support for authentication
  • 26. User request: support authentication • First implementation: accept user credentials (user + password), create authentication object using one of supported schemes (Basic, Windows etc.) • Worked like a charm, easy to use in client code var odataFeed = new ODataFeed( "http://www.myservice.com/api", "Vagif", "Password123"); • At that time Simple.Data OData adapter included non-portable version of Simple.OData.Client
  • 27. ODataFeed public class ODataFeed { public string Url { get; set; } public string User { get; set; } public string Password { get; set; } public string Domain { get; set; } public bool IntegratedSecurity { get; set; } }
  • 28. Creating Web request var request = (HttpWebRequest)WebRequest.Create(uri); if (this.Credentials.IntegratedSecurity) { request.Credentials = CredentialCache.DefaultNetworkCredentials; } else if (!string.IsNullOrEmpty(this.Credentials.User)) { request.Credentials = new NetworkCredential( this.Credentials.User, this.Credentials.Password, this.Credentials.Domain); }
  • 29. Merging with Portable branch Project doesn’t compile! • System.Net.CredentialCache: .NET 4.x only • System.Net.NetworkCredential: most of platforms
  • 30. What went wrong? • Simple.Data OData adapter took responsibility to create user credentials based on sensitive user information • Leaving aside security aspects, the adapter violated single responsibility principle • The adapter restricted supported authentication metods to those provided by credential creation code • The adapter is not open to extending it with new authentication methods, so it violated open/closed principle too • Use of interface segregation principle would avoid this mistake • PCL compliance forced use of interfaces
  • 31. Revised implementation In platform-spefic client code var odataFeed = new ODataFeed( "http://www.myservice.com/api", credentials); In Simple.OData.Client PCL var request = (HttpWebRequest)WebRequest.Create(uri); request.Credentials = this.Credentials;
  • 32. Revised implementation • Credentials is an instance of a class that implements System.Net.ICredentials interface • Neither Simple.Data OData adapter (.NET 4.x) nor Simple.OData.Client refer to a specific authentication scheme • All present and future authentication schemes are supported as long as they conform ICredentials
  • 33. Observations • Some SOLID principles require coding discipline and leave a room for interpretation, IMHO especially SRP and OCP (John Skeet on OCP: «While I've obviously considered the possibility that I'm the only one who finds it confusing, I've heard enough variation in the explanations of it to suggest that I'm really not the only one») • PCL conformance requirement doesn’t release you from the responsibility to make the design decision, but it can guard you from making obvious mistakes and sometimes even guide you in a right direction • PCLs make you more carefully plan service instantiation and use of non-functional utilities (logging, instrumentation etc.)
  • 34. PCLs and concrete classes • Portable class libraries do not push the work of implementing platform-specific services to client applications • PCLs can be packaged as a single portable deployment unit – Autofac – Json.NET – Simple.OData.Client • PCLs can also be compound, consisting of core portable and platform-specific parts – MetroLog – Splat
  • 36. MetroLog NuGet specification <files> <file src="MetroLog.dll" target="libportable-net45+ wp8+win8MetroLog.dll" /> <file src="MetroLog.dll" target="libnet45MetroLog.dll" /> <file src="MetroLog.NetFx.dll" target="libnet45MetroLog.NetFx.dll" /> <file src="MetroLog.dll" target="libnetcore45MetroLog.dll" /> <file src="MetroLog.NetCore.dll" target="libnetcore45MetroLog.NetCore.dll" /> </files>
  • 37. PCLs consuming PCLs • A PCL client can also be a portable library • Client target platforms must be a subset of the referenced PCL’s target platforms • Functionality that requires platform-specific services is usually referred using interfaces and abstract classes • There is a trick to use concrete platform-specific classes in client PCLs by placing in the referenced PCL a dummy class with the same API surface and assembly identity as the platform-specific class
  • 38. PCL profiles and portable subsets • Profile is a set of supported platforms • Portable subset is a family of profiles that expose certain version of .NET FX API surface area – Profile 78: Portable Subset: • .NET 4.5 • Windows Phone 8 • Windows Store – Profile 95: Portable Subset (Legacy): • .NET 4.0.3 and higher • Silverlight 4 and higher • Windows Phone 7 and higher • Windows Store
  • 39. PCLs for Android and iOS Demo: Xamarin .NET Mobility Scanner Example: Reflection API portability
  • 40. Polyglot programming with PCLs • Use right language to solve specific problems • C# provides the best ‘one size fits all’ choice • F# is very efficient for immutable data transformations, financial computations, machine learning • F# code can be packaged in a PCL and shared among different platforms (inluding Android and iOS!) – No official support to target Windows Phone 8 using F# PCL, but there is a workaround – Both PCL and F# support in Xamarin are work in progress (with changes being made literally while I am speaking now) • Core logic can be written in C# and F# and packaged as PCL, and UI is added using platform-specific tools
  • 41. PCLs for the future • Profiles for v.4.0 API surface are being deprecated • Visual Studio 2013 can open PCLs that target legacy platforms, but it will upgrade Silverlight to target version 5 and Windows Phone to target version 8 • Xamarin PCLs targets both v.4.0 and v.4.5 API surfaces • If a library target wide range of platforms (both 4.0 and 4.5), its NuGet package should include separate binaries for each surface • Consider only targeting v.4.5 API surface for new projects unless you need to support legacy platforms
  • 42. Using PCLs in UI • Use of portable class libraries can result in significant code reuse in cross-platform application development • Most popular approach to cross-platform UI with PCLs is to use MVVM pattern and package core services, models and view models in a portable library • Most popular MVVM frameworks that have PCLs are MvvmLights and MvvmCross • MvvmCross supports targeting Xamarin.iOS and Xamarin.Android (and provides phenomenal support at StackOverflow by @slodge)
  • 43. Example: Lions Roar • Developed by Sequence Agency • UI is built using MvvmCross • View models PCL (2463 LOC) • Entities PCL (691 LOC) • Supported plalforms – Windows Store (1166 LOC) – Windows Phone 8 (668) – Android Phone/Tablet (1172) – iPhone/iPad (2000 LOC)
  • 44. Using PCL in ODataPad UI • ODataPad views show images • Original view model design included core portable base view model (without image data) and platform-specific view models (with image data) • Small picture size makes possible storing images in base64 format and reuse a single view model in all platforms • Rendering images requires platform-specific value converters • A PCL with a design-time view model serves design data to all Visual Studio designers (Blend)
  • 45. Conclusion • Portable class libraries are not only for binary reuse • Packaging code as PCLs helps making code cleaner: – Extract interfaces – Unify platform-specific services – Inject service dependencies – Use portable data structures • Consider PCLs when choosing third party libraries – Ready for other platforms – Indication of a proper design – May only have dependencies to other portable libraries • Consider make your next library portable even if you only target a single platform!
  • 46. Resources • Daniel Plaisted «How to Make Portable Class Libraries Work for You» • Scott Hanselman «Cross-Platform Portable Class Libraries with .NET are Happening» Open source projects at GitHub: • AutoFac • MetroLog • Splat • MvvmCross • Simple.OData.Client
  • 47. Thank you! • Mail: vagif.abilov@gmail.com • Twitter: @ooobject • GitHub: object • BitBucket: object • Blog: http://bloggingabout.net/blogs/vagif/default.aspx The source code for this PCL Conformance Analyzer can be found at https://github.com/object/PclAnalyzer