SlideShare una empresa de Scribd logo
1 de 46
NuGet 3.0 
Transitioning from OData 
to JSON-LD 
Jeff Handley 
@JeffHandley
NuGet 3.0 
New UI for Visual Studio 
• Lots of new UI features 
New client/server API 
• Built for nuget.org availability, based on usage patterns 
Lots of code refactoring 
• Easier maintenance going forward
NuGet 3.0 Plans 
Aligned with Visual Studio “14” release cycle 
• Preview in the next release 
• Shipping for VS 2012 and VS 2013 
• Not shipping for VS 2010 
MSBuild will consume package references 
Solution Explorer integration 
Details at http://blog.nuget.org
Transitioning to the 
new client/server API 
Design retrospective
package repository 
remote server local folder 
package 
metadata from API unpacked into memory 
Visual Studio project system 
C# F# Windows Phone … 
file system 
/packages folder project system
Guiding principles 
BEFORE NUGET 3.0 
Bolt onto Visual Studio 
Heavy use of abstractions 
Comprehensive unit tests 
Generic client/server API (OData)
Visual Studio bolt-on 
Use Visual Studio API 
Same result as manually referencing libraries 
Integrate with most Visual Studio project systems 
Support VS-integrated source control
Abstractions 
IPackageRepository 
• nuget.org 
• Other remote servers 
• Folder on disk or network 
IPackage/IPackageMetadata 
• Remote 
• In-memory 
• On disk 
IPackageManager 
IProjectSystem 
• C# 
• F# 
• Windows Phone 
IFileSystem 
• Actual file system 
• Project systems 
• Source control 
LOOSE COUPLING & UNIT TESTING 
more than 80 other interfaces
Generic client/server API 
ANOTHER FORM OF LOOSE COUPLING 
Don’t couple the client to a server implementation 
Avoid versioning the server to add client features 
LINQ programming model for local and remote
NuGet.VisualStudio 
NuGet.Core 
PowerShell 
console 
package 
manager 
window 
VS IDE 
integration 
source control 
integration 
command 
extensions 
nuget.exe
NuGet.VisualStudio 
Visual Studio IDE integration 
• Output window logging 
• Settings (package sources) 
• Automatic package restore upon build 
• Garbage-collecting packages on VS restart 
• Extension update banner 
Visual Studio APIs 
• Project system integration 
• Actual package installation and uninstallation
NuGet.Core 
• Package authoring (including package analysis rules) 
• Package reading (OPC/Zip, data model w/validation, file conventions) 
• Semantic Version implementation 
• Target framework compatibility 
• Dependency resolver 
• Local and remote sources (API, HTTP, proxies, authentication) 
• NuGet.Config Processing (including hierarchical and extensible features) 
• 80+ interfaces
http://valleyreport.blogspot.com/2012/01 
/revised-dumping-ordinance-allows.html
Classes fulfilling multiple interfaces 
Project systems are also file systems 
• Add/remove files 
• Enforces VS project system and source control integration 
/packages folder is also a package repository 
• GetPackages() 
• AddPackage() 
• RemovePackage() 
Extension methods on interfaces to simulate multiple inheritance 
• 17 “extensions” classes that act as base classes 
33 “utility” classes to contain business logic
Extreme loose coupling 
Magic values trigger special handling several layers deep 
• FindPackage(id, version: null); 
Granular interfaces led to unmanageable parameter counts 
• ProjectSystemExtensions.DeleteFiles FxCop 
suppressions 
Events during operations allowed decoupled reactions 
• InstallWalker needs to report progress to the VS UI
http://www.flickr.com/photos/bump/2807032202/
No change was easy 
• 18 classes touched adding HTTP headers for downloads 
• Dozens of classes affected to add a new field to nuspec 
• Mocks require more work than the actual implementation 
• Extension methods are not compatible with mocking 
•We became afraid to touch the dependency resolver
Big changes needed 
Replacing API v2 with API v3
SQL Azure 
database 
Azure 
Blob 
Storage 
Gallery / API v2 
Azure web role (3 instances) 
EntityFramework 
code-first 
WCF Data 
Services and 
ASP.NET MVC 
and Razor 
OData 
Search and 
feed 
requests 
Content Delivery Network (CDN) 
Package 
downloads
Azure 
Blob 
Storage 
Search Service 
Azure worker role (3+ instances) 
Lucene.NET 
Full index loaded into memory 
Content Delivery Network (CDN) 
Metrics Service 
Azure website (3+ instances) 
SQL Azure 
database 
Search 
queries 
Package 
metadata 
requests 
Package 
downloads
JSON-LD 
http://json-ld.org/ 
{ 
"@context": "http://json-ld.org/contexts/person.jsonld", 
"@id": "http://dbpedia.org/resource/John_Lennon", 
"name": "John Lennon", 
"born": "1940-10-09", 
"spouse": "http://dbpedia.org/resource/Cynthia_Lennon" 
}
Creating the v3 client 
For the new UI
API v2 support 
The UI must support both v2 and v3 clients 
No clean surface area to re-implement 
• UI  install walker  API v2  install walker  API v2 
• IQueryable<IPackage> exposed throughout code
Infinite surface area 
Finite scenarios
Scenarios and clients 
1. Search 
2. Install specific version 
3. Install latest version 
4. Install with dependencies 
5. Install from cache 
6. Install into another project 
7. Check for updates 
8. Update and update all 
9. Restore 
1. Package manager UI 
2. PowerShell console 
3. nuget.exe
http://www.clayburn.wtf/2011/03/to 
p-5-reasons-youre-unemployed.html
API v3 
search 
(feed) 
Search Service 
Azure worker role (3+ instances) 
Lucene.NET 
Full Index Loaded into Memory 
Gallery / API v2 
Azure web role (3+ instances) 
Content Delivery Network (CDN) 
API v3 
Package 
Metadata 
Package 
Downloads 
Metrics Service 
Azure website (3+ instances) 
API v2 
OData 
SQL Azure 
database 
Azure 
Blob 
Storage
WCF Data Services to the rescue!? 
NuGet 
Core 
WCF Data 
Services 
API v2 
Server 
OData 
XML 
WCF Data 
Services 
Entity 
Framework 
API v3 
Services 
JSON-LD 
Convert JSON-LD to XML
http://www.marcioezequiel.com 
.br/2013/10/bigode-grosso.html
Introducing NuGet.Client 
Handle the client/server scenarios 
Support API v2 and API v3 
Scenario-focused object model 
Prevent new dependencies on NuGet.Core
Wrapping NuGet.Core 
Package Manager UI 
NuGet.Core 
NuGet.Client
Dealing with deep API v2 assumptions 
• Implemented v2 interfaces in v3 classes 
• Threw NotImplementedException on all members 
• Ran a scenario, identified code paths required 
• Identified more concrete API v3 requirements 
• Discovered data needed for each scenario 
• Influenced API v3 JSON-LD views
Shrinking NuGet.Core 
Package Manager UI 
NuGet.Core 
Package 
Authoring 
Package 
Reading 
Semantic 
Versioning 
Target FX 
Compat 
Dependency 
Resolver 
Local 
Package 
Sources 
NuGet 
Config 
Processing 
Project and 
NuGet.Core 
NuGet.Client 
NuGet.Client File Systems
Compromises 
API v3 isn’t completely “clean” yet 
• It exposes the API v2 interfaces 
Chatty 
• API v3 uses more HTTP requests than a pure v3 server/client would 
• API v2 interop performs more OData requests than we used to 
Out of scope 
• PowerShell console 
• nuget.exe
New guiding principles 
Our new rules
Guiding principle #1 
Technology is not a substitute 
for understanding our scenarios.
Guiding principle #2 
Don’t expose IQueryable on 
public API. 
* this applies to our RESTful services too
Guiding principle #3 
Every client/server scenario 
needs an explicit endpoint.
Guiding principle #4 
Shipping is more valuable than 
code purity.
Guiding principle #5 
Don’t implement interfaces just 
because the members match.
Guiding principle #6 
Side-effecting event handlers 
hurt in unpredictable ways.
Guiding principle #7 
Avoid business logic in extension 
methods. They can’t be mocked.
Guiding principle #8 
If adding new business logic is 
hard, refactor right away.
Thanks 
Come get NuGet stickers 
@jeffhandley | jeffhandley.com | jeff.handley@microsoft.com | blog.nuget.org

Más contenido relacionado

La actualidad más candente

Jenkins Workflow Webinar - Dec 10, 2014
Jenkins Workflow Webinar - Dec 10, 2014Jenkins Workflow Webinar - Dec 10, 2014
Jenkins Workflow Webinar - Dec 10, 2014
CloudBees
 

La actualidad más candente (20)

DockerCon SF 2015: Docker in the New York Times Newsroom
DockerCon SF 2015: Docker in the New York Times NewsroomDockerCon SF 2015: Docker in the New York Times Newsroom
DockerCon SF 2015: Docker in the New York Times Newsroom
 
What’s New in Spring Batch?
What’s New in Spring Batch?What’s New in Spring Batch?
What’s New in Spring Batch?
 
CI/CD 기반의 Microservice 개발
 CI/CD 기반의 Microservice 개발 CI/CD 기반의 Microservice 개발
CI/CD 기반의 Microservice 개발
 
Orchestrating Microservices with Kubernetes
Orchestrating Microservices with Kubernetes Orchestrating Microservices with Kubernetes
Orchestrating Microservices with Kubernetes
 
Security model for a remote company
Security model for a remote companySecurity model for a remote company
Security model for a remote company
 
Ultimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on KubernetesUltimate Guide to Microservice Architecture on Kubernetes
Ultimate Guide to Microservice Architecture on Kubernetes
 
Introduction to GitHub Actions - How to easily automate and integrate with Gi...
Introduction to GitHub Actions - How to easily automate and integrate with Gi...Introduction to GitHub Actions - How to easily automate and integrate with Gi...
Introduction to GitHub Actions - How to easily automate and integrate with Gi...
 
Continuous Delivery the Hard Way with Kubernetes
Continuous Delivery the Hard Way with Kubernetes Continuous Delivery the Hard Way with Kubernetes
Continuous Delivery the Hard Way with Kubernetes
 
Windows container security
Windows container securityWindows container security
Windows container security
 
Load Balancing in the Cloud using Nginx & Kubernetes
Load Balancing in the Cloud using Nginx & KubernetesLoad Balancing in the Cloud using Nginx & Kubernetes
Load Balancing in the Cloud using Nginx & Kubernetes
 
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems IntegrationJenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
Jenkins Pipeline @ Scale. Building Automation Frameworks for Systems Integration
 
OpenShift for Java EE Developers
OpenShift for Java EE DevelopersOpenShift for Java EE Developers
OpenShift for Java EE Developers
 
Greach 2014 - Road to Grails 3.0
Greach 2014  - Road to Grails 3.0Greach 2014  - Road to Grails 3.0
Greach 2014 - Road to Grails 3.0
 
Introduction to Kubernetes Security (Aqua & Weaveworks)
Introduction to Kubernetes Security (Aqua & Weaveworks)Introduction to Kubernetes Security (Aqua & Weaveworks)
Introduction to Kubernetes Security (Aqua & Weaveworks)
 
NATS: Simple, Secure and Scalable Messaging For the Cloud Native Era
NATS: Simple, Secure and Scalable Messaging For the Cloud Native EraNATS: Simple, Secure and Scalable Messaging For the Cloud Native Era
NATS: Simple, Secure and Scalable Messaging For the Cloud Native Era
 
Provisioning Servers Made Easy
Provisioning Servers Made EasyProvisioning Servers Made Easy
Provisioning Servers Made Easy
 
Jenkins Workflow Webinar - Dec 10, 2014
Jenkins Workflow Webinar - Dec 10, 2014Jenkins Workflow Webinar - Dec 10, 2014
Jenkins Workflow Webinar - Dec 10, 2014
 
DCSF19 Docker Containers & Java: What I Wish I Had Been Told
DCSF19 Docker Containers & Java: What I Wish I Had Been ToldDCSF19 Docker Containers & Java: What I Wish I Had Been Told
DCSF19 Docker Containers & Java: What I Wish I Had Been Told
 
Demystifying container connectivity with kubernetes in docker
Demystifying container connectivity with kubernetes in dockerDemystifying container connectivity with kubernetes in docker
Demystifying container connectivity with kubernetes in docker
 
My kubernetes toolkit
My kubernetes toolkitMy kubernetes toolkit
My kubernetes toolkit
 

Destacado

Running in the Cloud - First Belgian Azure project
Running in the Cloud - First Belgian Azure projectRunning in the Cloud - First Belgian Azure project
Running in the Cloud - First Belgian Azure project
Maarten Balliauw
 
Fun with ASP.NET MVC 3, MEF and NuGet (#comdaybe)
Fun with ASP.NET MVC 3, MEF and NuGet (#comdaybe)Fun with ASP.NET MVC 3, MEF and NuGet (#comdaybe)
Fun with ASP.NET MVC 3, MEF and NuGet (#comdaybe)
Maarten Balliauw
 
An overview of the NuGet ecosystem - Mobel.io
An overview of the NuGet ecosystem - Mobel.ioAn overview of the NuGet ecosystem - Mobel.io
An overview of the NuGet ecosystem - Mobel.io
Maarten Balliauw
 

Destacado (20)

Running in the Cloud - First Belgian Azure project
Running in the Cloud - First Belgian Azure projectRunning in the Cloud - First Belgian Azure project
Running in the Cloud - First Belgian Azure project
 
Fun with ASP.NET MVC 3, MEF and NuGet (#comdaybe)
Fun with ASP.NET MVC 3, MEF and NuGet (#comdaybe)Fun with ASP.NET MVC 3, MEF and NuGet (#comdaybe)
Fun with ASP.NET MVC 3, MEF and NuGet (#comdaybe)
 
An overview of the NuGet ecosystem - Mobel.io
An overview of the NuGet ecosystem - Mobel.ioAn overview of the NuGet ecosystem - Mobel.io
An overview of the NuGet ecosystem - Mobel.io
 
Understanding NuGet implementation for Enterprises
Understanding NuGet implementation for EnterprisesUnderstanding NuGet implementation for Enterprises
Understanding NuGet implementation for Enterprises
 
OData, Open Data Protocol. A brief introduction
OData, Open Data Protocol. A brief introductionOData, Open Data Protocol. A brief introduction
OData, Open Data Protocol. A brief introduction
 
NuGet vs Maven
NuGet vs MavenNuGet vs Maven
NuGet vs Maven
 
Using nu get the way you should svcc
Using nu get the way you should   svccUsing nu get the way you should   svcc
Using nu get the way you should svcc
 
Using NuGet the way you should - TechDays NL 2014
Using NuGet the way you should - TechDays NL 2014Using NuGet the way you should - TechDays NL 2014
Using NuGet the way you should - TechDays NL 2014
 
Developing NuGet
Developing NuGetDeveloping NuGet
Developing NuGet
 
The API Tempest
The API TempestThe API Tempest
The API Tempest
 
Elegant Rest Design Webinar
Elegant Rest Design WebinarElegant Rest Design Webinar
Elegant Rest Design Webinar
 
Build A Killer Client For Your REST+JSON API
Build A Killer Client For Your REST+JSON APIBuild A Killer Client For Your REST+JSON API
Build A Killer Client For Your REST+JSON API
 
Gestion paquetes NuGet con Visual Studio Team Services y MyGet
Gestion paquetes NuGet con Visual Studio Team Services y MyGetGestion paquetes NuGet con Visual Studio Team Services y MyGet
Gestion paquetes NuGet con Visual Studio Team Services y MyGet
 
JSON-LD for RESTful services
JSON-LD for RESTful servicesJSON-LD for RESTful services
JSON-LD for RESTful services
 
Hortonworks Data In Motion Series Part 4
Hortonworks Data In Motion Series Part 4Hortonworks Data In Motion Series Part 4
Hortonworks Data In Motion Series Part 4
 
Custom Data Search with Stormpath
Custom Data Search with StormpathCustom Data Search with Stormpath
Custom Data Search with Stormpath
 
JWTs in Java for CSRF and Microservices
JWTs in Java for CSRF and MicroservicesJWTs in Java for CSRF and Microservices
JWTs in Java for CSRF and Microservices
 
Protecting Your APIs Against Attack & Hijack
Protecting Your APIs Against Attack & Hijack Protecting Your APIs Against Attack & Hijack
Protecting Your APIs Against Attack & Hijack
 
Getting Started With Angular
Getting Started With AngularGetting Started With Angular
Getting Started With Angular
 
Instant Security & Scalable User Management with Spring Boot
Instant Security & Scalable User Management with Spring BootInstant Security & Scalable User Management with Spring Boot
Instant Security & Scalable User Management with Spring Boot
 

Similar a NuGet 3.0 - Transitioning from OData to JSON-LD

Similar a NuGet 3.0 - Transitioning from OData to JSON-LD (20)

Open shift and docker - october,2014
Open shift and docker - october,2014Open shift and docker - october,2014
Open shift and docker - october,2014
 
.NET Core Apps: Design & Development
.NET Core Apps: Design & Development.NET Core Apps: Design & Development
.NET Core Apps: Design & Development
 
Vijay Oscon
Vijay OsconVijay Oscon
Vijay Oscon
 
ASP.NET vNext
ASP.NET vNextASP.NET vNext
ASP.NET vNext
 
04_Azure Kubernetes Service: Basic Practices for Developers_GAB2019
04_Azure Kubernetes Service: Basic Practices for Developers_GAB201904_Azure Kubernetes Service: Basic Practices for Developers_GAB2019
04_Azure Kubernetes Service: Basic Practices for Developers_GAB2019
 
Tokyo Azure Meetup #7 - Introduction to Serverless Architectures with Azure F...
Tokyo Azure Meetup #7 - Introduction to Serverless Architectures with Azure F...Tokyo Azure Meetup #7 - Introduction to Serverless Architectures with Azure F...
Tokyo Azure Meetup #7 - Introduction to Serverless Architectures with Azure F...
 
Azure DevOps for JavaScript Developers
Azure DevOps for JavaScript DevelopersAzure DevOps for JavaScript Developers
Azure DevOps for JavaScript Developers
 
What's New in .Net 4.5
What's New in .Net 4.5What's New in .Net 4.5
What's New in .Net 4.5
 
Best of Microsoft Dev Camp 2015
Best of Microsoft Dev Camp 2015Best of Microsoft Dev Camp 2015
Best of Microsoft Dev Camp 2015
 
Red Hat Forum Benelux 2015
Red Hat Forum Benelux 2015Red Hat Forum Benelux 2015
Red Hat Forum Benelux 2015
 
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
 
Azure serverless architectures
Azure serverless architecturesAzure serverless architectures
Azure serverless architectures
 
DEVNET-1166 Open SDN Controller APIs
DEVNET-1166	Open SDN Controller APIsDEVNET-1166	Open SDN Controller APIs
DEVNET-1166 Open SDN Controller APIs
 
Mete Atamel
Mete AtamelMete Atamel
Mete Atamel
 
VMworld 2013: vSphere UI Platform Best Practices: Putting the Web Client SDK ...
VMworld 2013: vSphere UI Platform Best Practices: Putting the Web Client SDK ...VMworld 2013: vSphere UI Platform Best Practices: Putting the Web Client SDK ...
VMworld 2013: vSphere UI Platform Best Practices: Putting the Web Client SDK ...
 
JSS build and deployment
JSS build and deploymentJSS build and deployment
JSS build and deployment
 
Windows azure overview for SharePoint Pros
Windows azure overview for SharePoint Pros Windows azure overview for SharePoint Pros
Windows azure overview for SharePoint Pros
 
Deep Dive Azure Functions - Global Azure Bootcamp 2019
Deep Dive Azure Functions - Global Azure Bootcamp 2019Deep Dive Azure Functions - Global Azure Bootcamp 2019
Deep Dive Azure Functions - Global Azure Bootcamp 2019
 
Taking Spring Apps for a Spin on Microsoft Azure Cloud
Taking Spring Apps for a Spin on Microsoft Azure CloudTaking Spring Apps for a Spin on Microsoft Azure Cloud
Taking Spring Apps for a Spin on Microsoft Azure Cloud
 
ASP.NET Core 1.0
ASP.NET Core 1.0ASP.NET Core 1.0
ASP.NET Core 1.0
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

NuGet 3.0 - Transitioning from OData to JSON-LD

  • 1. NuGet 3.0 Transitioning from OData to JSON-LD Jeff Handley @JeffHandley
  • 2. NuGet 3.0 New UI for Visual Studio • Lots of new UI features New client/server API • Built for nuget.org availability, based on usage patterns Lots of code refactoring • Easier maintenance going forward
  • 3.
  • 4. NuGet 3.0 Plans Aligned with Visual Studio “14” release cycle • Preview in the next release • Shipping for VS 2012 and VS 2013 • Not shipping for VS 2010 MSBuild will consume package references Solution Explorer integration Details at http://blog.nuget.org
  • 5. Transitioning to the new client/server API Design retrospective
  • 6. package repository remote server local folder package metadata from API unpacked into memory Visual Studio project system C# F# Windows Phone … file system /packages folder project system
  • 7. Guiding principles BEFORE NUGET 3.0 Bolt onto Visual Studio Heavy use of abstractions Comprehensive unit tests Generic client/server API (OData)
  • 8. Visual Studio bolt-on Use Visual Studio API Same result as manually referencing libraries Integrate with most Visual Studio project systems Support VS-integrated source control
  • 9. Abstractions IPackageRepository • nuget.org • Other remote servers • Folder on disk or network IPackage/IPackageMetadata • Remote • In-memory • On disk IPackageManager IProjectSystem • C# • F# • Windows Phone IFileSystem • Actual file system • Project systems • Source control LOOSE COUPLING & UNIT TESTING more than 80 other interfaces
  • 10. Generic client/server API ANOTHER FORM OF LOOSE COUPLING Don’t couple the client to a server implementation Avoid versioning the server to add client features LINQ programming model for local and remote
  • 11. NuGet.VisualStudio NuGet.Core PowerShell console package manager window VS IDE integration source control integration command extensions nuget.exe
  • 12. NuGet.VisualStudio Visual Studio IDE integration • Output window logging • Settings (package sources) • Automatic package restore upon build • Garbage-collecting packages on VS restart • Extension update banner Visual Studio APIs • Project system integration • Actual package installation and uninstallation
  • 13. NuGet.Core • Package authoring (including package analysis rules) • Package reading (OPC/Zip, data model w/validation, file conventions) • Semantic Version implementation • Target framework compatibility • Dependency resolver • Local and remote sources (API, HTTP, proxies, authentication) • NuGet.Config Processing (including hierarchical and extensible features) • 80+ interfaces
  • 15. Classes fulfilling multiple interfaces Project systems are also file systems • Add/remove files • Enforces VS project system and source control integration /packages folder is also a package repository • GetPackages() • AddPackage() • RemovePackage() Extension methods on interfaces to simulate multiple inheritance • 17 “extensions” classes that act as base classes 33 “utility” classes to contain business logic
  • 16. Extreme loose coupling Magic values trigger special handling several layers deep • FindPackage(id, version: null); Granular interfaces led to unmanageable parameter counts • ProjectSystemExtensions.DeleteFiles FxCop suppressions Events during operations allowed decoupled reactions • InstallWalker needs to report progress to the VS UI
  • 18. No change was easy • 18 classes touched adding HTTP headers for downloads • Dozens of classes affected to add a new field to nuspec • Mocks require more work than the actual implementation • Extension methods are not compatible with mocking •We became afraid to touch the dependency resolver
  • 19. Big changes needed Replacing API v2 with API v3
  • 20. SQL Azure database Azure Blob Storage Gallery / API v2 Azure web role (3 instances) EntityFramework code-first WCF Data Services and ASP.NET MVC and Razor OData Search and feed requests Content Delivery Network (CDN) Package downloads
  • 21. Azure Blob Storage Search Service Azure worker role (3+ instances) Lucene.NET Full index loaded into memory Content Delivery Network (CDN) Metrics Service Azure website (3+ instances) SQL Azure database Search queries Package metadata requests Package downloads
  • 22. JSON-LD http://json-ld.org/ { "@context": "http://json-ld.org/contexts/person.jsonld", "@id": "http://dbpedia.org/resource/John_Lennon", "name": "John Lennon", "born": "1940-10-09", "spouse": "http://dbpedia.org/resource/Cynthia_Lennon" }
  • 23. Creating the v3 client For the new UI
  • 24. API v2 support The UI must support both v2 and v3 clients No clean surface area to re-implement • UI  install walker  API v2  install walker  API v2 • IQueryable<IPackage> exposed throughout code
  • 25.
  • 26. Infinite surface area Finite scenarios
  • 27. Scenarios and clients 1. Search 2. Install specific version 3. Install latest version 4. Install with dependencies 5. Install from cache 6. Install into another project 7. Check for updates 8. Update and update all 9. Restore 1. Package manager UI 2. PowerShell console 3. nuget.exe
  • 29. API v3 search (feed) Search Service Azure worker role (3+ instances) Lucene.NET Full Index Loaded into Memory Gallery / API v2 Azure web role (3+ instances) Content Delivery Network (CDN) API v3 Package Metadata Package Downloads Metrics Service Azure website (3+ instances) API v2 OData SQL Azure database Azure Blob Storage
  • 30. WCF Data Services to the rescue!? NuGet Core WCF Data Services API v2 Server OData XML WCF Data Services Entity Framework API v3 Services JSON-LD Convert JSON-LD to XML
  • 32. Introducing NuGet.Client Handle the client/server scenarios Support API v2 and API v3 Scenario-focused object model Prevent new dependencies on NuGet.Core
  • 33. Wrapping NuGet.Core Package Manager UI NuGet.Core NuGet.Client
  • 34. Dealing with deep API v2 assumptions • Implemented v2 interfaces in v3 classes • Threw NotImplementedException on all members • Ran a scenario, identified code paths required • Identified more concrete API v3 requirements • Discovered data needed for each scenario • Influenced API v3 JSON-LD views
  • 35. Shrinking NuGet.Core Package Manager UI NuGet.Core Package Authoring Package Reading Semantic Versioning Target FX Compat Dependency Resolver Local Package Sources NuGet Config Processing Project and NuGet.Core NuGet.Client NuGet.Client File Systems
  • 36. Compromises API v3 isn’t completely “clean” yet • It exposes the API v2 interfaces Chatty • API v3 uses more HTTP requests than a pure v3 server/client would • API v2 interop performs more OData requests than we used to Out of scope • PowerShell console • nuget.exe
  • 37. New guiding principles Our new rules
  • 38. Guiding principle #1 Technology is not a substitute for understanding our scenarios.
  • 39. Guiding principle #2 Don’t expose IQueryable on public API. * this applies to our RESTful services too
  • 40. Guiding principle #3 Every client/server scenario needs an explicit endpoint.
  • 41. Guiding principle #4 Shipping is more valuable than code purity.
  • 42. Guiding principle #5 Don’t implement interfaces just because the members match.
  • 43. Guiding principle #6 Side-effecting event handlers hurt in unpredictable ways.
  • 44. Guiding principle #7 Avoid business logic in extension methods. They can’t be mocked.
  • 45. Guiding principle #8 If adding new business logic is hard, refactor right away.
  • 46. Thanks Come get NuGet stickers @jeffhandley | jeffhandley.com | jeff.handley@microsoft.com | blog.nuget.org

Notas del editor

  1. Demo the new UI Consolidation of Online, Installed, and Updates workflows Search respects target framework Version selection (for both installing and updating) Preview Installation Options Multiple windows Solution-Level management of versions installed
  2. We thought JSON would save us!
  3. Searching for the contract