SlideShare a Scribd company logo
1 of 24
Download to read offline
ライブラリ開発者のための
おいしいナゲットの揚げ方
2014/08/10 Comb meet up!
自己紹介
azyobuzin / ぺぺたろう / ひゅいっ
 Twitter, GitHub, etc: @azyobuzin
 Blog: azyobuzin.hatenablog.com
 C# と Python が好きっていう建前
 PSO2: あじょぶじん @Ship4
 エディタ: サクラエディタ, nano
のヮの<私、大きな事故はしたことない
❝
5分で終わる気がしない
(*1)LT… 自分の興味のある分野について、持ち時間5分で短いプレゼ
ンテーションを行うことです。
話を簡潔に纏めることで、聞き手に飽きさせず、興味を持たせる狙い
があります。
(*2)Talk… 持ち時間10分前後で、LTより少し内容の深いプレゼン
テーションを行います。していく形となります。
❞http://www.comb.club/comb-meetup.html
NuGet
ワンクリック/ワンコマンドで
ライブラリをダウンロードできるアレ
for .NET
パッケージの構造
Q. どれが使われるの?
A. 点数化して一番良さそうなのが
選び出される
格付けし合う
プラットフォームたち
確認 Portable Class Library
 プラットフォームをまたいで使えるライブラリ
 例: ストアアプリでも Xamarin でも使える
 .NET Framework クラスライブラリから共通するものだけを抽出
 基本的に使いたい機能は大体無いと思うべし
クライアントアプリ開発では
 プラットフォーム非依存のコードをまとめておく
ライブラリ開発では
 共通して使えるメンバーを定義だけしておく
 実装は各プラットフォーム向けアセンブリに任せよう(NuGetマジック)
配点
互換性があると判断されたアセンブリに点数をつける
単一プラットフォーム
ターゲットが少ない PCL
ターゲットが多い PCL
NuGet.VersionUtility
.GetProfileCompatibility
(private メソッド)
注意
実際のソースコードをかなり改変した上に
到達する条件がわからなかった部分を排除してあります
単一プラットフォーム
long compatibility = 0;
compatibility += CalculateVersionDistance(
projectFrameworkName.Version,
GetEffectiveFrameworkVersion(
projectFrameworkName, packageTargetFrameworkName,
portableProfileTable));
if (packageTargetFrameworkName.Profile.Equals(projectFrameworkName.Profile))
compatibility++;
if (packageTargetFrameworkName.Identifier.Equals(projectFrameworkName.Identifier))
compatibility += 10 * (1L << 32);
単一プラットフォーム
long compatibility = 0;
compatibility += CalculateVersionDistance(
projectFrameworkName.Version,
GetEffectiveFrameworkVersion(
projectFrameworkName, packageTargetFrameworkName,
portableProfileTable));
if (packageTargetFrameworkName.Profile.Equals(projectFrameworkName.Profile))
compatibility++;
if (packageTargetFrameworkName.Identifier.Equals(projectFrameworkName.Identifier))
compatibility += 10 * (1L << 32);
バージョンが近いほど
大きな値に
プロファイルが同じなら
大きな値に
Client Profile 滅べ
PCL と差をつける
PCL(プロジェクトは単一プラットフォーム)
var compatibleFramework = packageFrameworkProfile.SupportedFrameworks
.FirstOrDefault(f => IsCompatible(projectFrameworkName, f, portableProfileTable));
var score = GetProfileCompatibility(projectFrameworkName, compatibleFramework,
portableProfileTable);
score -= (packageFrameworkProfile.SupportedFrameworks.Count * 2);
return score / 2;
PCL(プロジェクトは単一プラットフォーム)
var compatibleFramework = packageFrameworkProfile.SupportedFrameworks
.FirstOrDefault(f => IsCompatible(projectFrameworkName, f, portableProfileTable));
var score = GetProfileCompatibility(projectFrameworkName, compatibleFramework,
portableProfileTable);
score -= (packageFrameworkProfile.SupportedFrameworks.Count * 2);
return score / 2;
PCL でカバーしてるプラットフォームから
プロジェクトと互換性があるのを 1 つ取り出す
取り出したプラットフォームと
プロジェクトのプラットフォームで比較
カバーしてるプラットフォームの数だけ減点さらに減点
PCL(プロジェクトもPCL)
int nonMatchingCompatibleFrameworkCount = 0;
foreach (var supportedPackageTargetFramework in
packageTargetFrameworkProfile.SupportedFrameworks) {
var compatibleProjectFramework = projectFrameworkProfile.SupportedFrameworks
.FirstOrDefault(f => IsCompatible(f, supportedPackageTargetFramework,
portableProfileTable));
if (compatibleProjectFramework != null &&
compatibleProjectFramework.Version > supportedPackageTargetFramework.Version)
nonMatchingCompatibleFrameworkCount++;
}
int score = nonMatchingCompatibleFrameworkCount;
score = -(score * 50 + packageTargetFrameworkProfile.SupportedFrameworks.Count);
PCL(プロジェクトもPCL)
int nonMatchingCompatibleFrameworkCount = 0;
foreach (var supportedPackageTargetFramework in
packageTargetFrameworkProfile.SupportedFrameworks) {
var compatibleProjectFramework = projectFrameworkProfile.SupportedFrameworks
.FirstOrDefault(f => IsCompatible(f, supportedPackageTargetFramework,
portableProfileTable));
if (compatibleProjectFramework != null &&
compatibleProjectFramework.Version > supportedPackageTargetFramework.Version)
nonMatchingCompatibleFrameworkCount++;
}
int score = nonMatchingCompatibleFrameworkCount;
score = -(score * 50 + packageTargetFrameworkProfile.SupportedFrameworks.Count);
同一プラットフォームで
バージョンが違ったら減点
対応しているプラットフォームの
数だけ減点
大幅に減点
なるほど、わからん
NuGetCalc
 https://github.com/azyobuzin/NuGetCalc
 NuGet でインストールされるアセンブリを予測するツール
 おとといがんばってつくった
> NuGetCalc CoreTweet portable-win8+wpa81
.NETPortable,Version=v0.0,Profile=net4+sl5+wp8+win8+wpa81+MonoAndroid+MonoTouch
> NuGetCalc -v CoreTweet net45
.NETFramework,Version=v4.5 180388626433
.NETFramework,Version=v4.0 180388301308
.NETFramework,Version=v3.5 180372045058
.NETPortable,Version=v0.0,Profile=net45+MonoAndroid+MonoTouch 90194313213
.NETPortable,Version=v0.0,Profile=net4+sl5+wp8+win8+wpa81+MonoAndroid+MonoTouch
90194150647
.NET 関係の人へ
どのアセンブリが
使われるかを意識して
NuGet パッケージをつくろう
.NET 触ったことない人へ
C# 楽しいよ
マサカリ受け入れ準備完了
おしまい

More Related Content

Recently uploaded

Recently uploaded (7)

業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
 
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
 
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
 
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイスLoRaWANスマート距離検出センサー  DS20L  カタログ  LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
 
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半        2024/04/26の勉強会で発表されたものです。新人研修 後半        2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。
 
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアルLoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
 
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
 

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

ライブラリ開発者のためのおいしいナゲットの揚げ方