Download free for 30 days
Sign in
Upload
Language (EN)
Support
Business
Mobile
Social Media
Marketing
Technology
Art & Photos
Career
Design
Education
Presentations & Public Speaking
Government & Nonprofit
Healthcare
Internet
Law
Leadership & Management
Automotive
Engineering
Software
Recruiting & HR
Retail
Sales
Services
Science
Small Business & Entrepreneurship
Food
Environment
Economy & Finance
Data & Analytics
Investor Relations
Sports
Spiritual
News & Politics
Travel
Self Improvement
Real Estate
Entertainment & Humor
Health & Medicine
Devices & Hardware
Lifestyle
Change Language
Language
English
Español
Português
Français
Deutsche
Cancel
Save
Submit search
EN
Uploaded by
Hideharu MATSUFUJI
PDF, PPTX
1,377 views
PHPカンファレンス関西2017 PHPにおけるDSL
PHPカンファレンス関西2017 PHPにおけるDSL
Engineering
◦
Read more
1
Save
Share
Embed
Download
Download as PDF, PPTX
1
/ 20
2
/ 20
3
/ 20
4
/ 20
5
/ 20
6
/ 20
7
/ 20
8
/ 20
9
/ 20
10
/ 20
11
/ 20
12
/ 20
13
/ 20
14
/ 20
15
/ 20
16
/ 20
17
/ 20
18
/ 20
19
/ 20
20
/ 20
More Related Content
PDF
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
by
OECD Directorate for Financial and Enterprise Affairs
PDF
Storytelling For The Web: Integrate Storytelling in your Design Process
by
Chiara Aliotta
PDF
2024 Trend Updates: What Really Works In SEO & Content Marketing
by
Search Engine Journal
PDF
Gulpで学ぶSassとPug
by
シオリ ショウノ
PDF
KOF2017 東海道らぐLT
by
Masataka Kondo
PPTX
Geek women japanのロゴをhtmlとcssで作る
by
Lina Katayose
PPTX
Geek women japanのロゴをhtmlとcssで作る2
by
Lina Katayose
PDF
まっつんチャレンジ OSC出張編 45分でわかる PHP+Eclipseによるテスト駆動開発環境の構築
by
Hideharu MATSUFUJI
Artificial Intelligence, Data and Competition – SCHREPEL – June 2024 OECD dis...
by
OECD Directorate for Financial and Enterprise Affairs
Storytelling For The Web: Integrate Storytelling in your Design Process
by
Chiara Aliotta
2024 Trend Updates: What Really Works In SEO & Content Marketing
by
Search Engine Journal
Gulpで学ぶSassとPug
by
シオリ ショウノ
KOF2017 東海道らぐLT
by
Masataka Kondo
Geek women japanのロゴをhtmlとcssで作る
by
Lina Katayose
Geek women japanのロゴをhtmlとcssで作る2
by
Lina Katayose
まっつんチャレンジ OSC出張編 45分でわかる PHP+Eclipseによるテスト駆動開発環境の構築
by
Hideharu MATSUFUJI
Featured
PDF
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
by
SocialHRCamp
PDF
2024 State of Marketing Report – by Hubspot
by
Marius Sescu
PDF
Everything You Need To Know About ChatGPT
by
Expeed Software
PDF
Product Design Trends in 2024 | Teenage Engineerings
by
Pixeldarts
PDF
How Race, Age and Gender Shape Attitudes Towards Mental Health
by
ThinkNow
PDF
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
by
marketingartwork
PDF
Skeleton Culture Code
by
Skeleton Technologies
PDF
PEPSICO Presentation to CAGNY Conference Feb 2024
by
Neil Kimberley
PDF
Content Methodology: A Best Practices Report (Webinar)
by
contently
PPTX
How to Prepare For a Successful Job Search for 2024
by
Albert Qian
PDF
Social Media Marketing Trends 2024 // The Global Indie Insights
by
Kurio // The Social Media Age(ncy)
PDF
Trends In Paid Search: Navigating The Digital Landscape In 2024
by
Search Engine Journal
PDF
5 Public speaking tips from TED - Visualized summary
by
SpeakerHub
PDF
ChatGPT and the Future of Work - Clark Boyd
by
Clark Boyd
PDF
Getting into the tech field. what next
by
Tessa Mero
PDF
Google's Just Not That Into You: Understanding Core Updates & Search Intent
by
Lily Ray
PDF
How to have difficult conversations
by
Rajiv Jayarajah, MAppComm, ACC
PDF
Introduction to Data Science
by
Christy Abraham Joy
PDF
Time Management & Productivity - Best Practices
by
Vit Horky
PDF
The six step guide to practical project management
by
MindGenius
How to Leverage AI to Boost Employee Wellness - Lydia Di Francesco - SocialHR...
by
SocialHRCamp
2024 State of Marketing Report – by Hubspot
by
Marius Sescu
Everything You Need To Know About ChatGPT
by
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
by
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
by
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
by
marketingartwork
Skeleton Culture Code
by
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
by
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
by
contently
How to Prepare For a Successful Job Search for 2024
by
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
by
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
by
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
by
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
by
Clark Boyd
Getting into the tech field. what next
by
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
by
Lily Ray
How to have difficult conversations
by
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
by
Christy Abraham Joy
Time Management & Productivity - Best Practices
by
Vit Horky
The six step guide to practical project management
by
MindGenius
PHPカンファレンス関西2017 PHPにおけるDSL
1.
PHPにおける DSL PHPカンファレンス関西 2017 松藤 秀治
(2017-7-15)
2.
じこしょうかい ● 松藤 秀治(まつふじ ひではる) ● matsu_hide ●
フリーエンジニア/ND&I
3.
はじめに ● 「PHPでDSLを使ってみるための一例」です。 ● 「他にもこんな実装があるよー」という方はぜひ教えてく ださい! ●
いろいろ抜けているトピックが多々多々多々あると思いま すが、生暖かい目で見ていただけると助かります(_ _)
4.
DSLの例 SQL → RDBへの問い合わせ言語 シェルスクリプト
→ Unixなどで利用 CSS → HTMLの体裁を表現する
5.
PHPはDSL? 「PHPは、最初の時点ではWebページ作成に使うツールを集 めたフレームワークであり、作者としても「スクリプト言語を作 るなどといった考えはまったくなかった」のであるが・・・」 (Wikipedia) DSLから汎用のプログラミング言語に発展
6.
DSLってなに? Domain Specific Language
(ドメイン特化(固有)言語) 「DSLとは、小さな問題領域に的を絞ったカスタム言語であ る。DSLは、その領域に固有の表現で記述し、検証する。」 (ドメイン特化型開発 p.12)
7.
それがない世界 RDBへの問い合わせをSQLを使わずに書く? WebページをHTMLだけでデザインする? 問題領域に適した表現で記述することで理解しやすくなり、 生産性が上がる。⇒変化に強くなる
8.
今回の問題領域(サンプル) ECサイトである条件を満たすとき割引する。 「キャンペーン商品を含んでいる場合は合計金額から10%値 下げしたい。」 「合計金額が1000円を超えたら、送料無料にしたい。」
9.
実践!DSL パーサー(構文解析) エンジン エディター
10.
実践!DSL orz
11.
実践!DSL パーサー ⇒ YAML エンジン
⇒ ExpressionLanguage (Symfony) エディター ⇒ あきらめる (or Xtext)
12.
ExpressionLanguage Component 式をコンパイルして、評価するエンジン。 ワンライナー(戻り値はbooleanでなくても可) Symfonyが提供しているコンポーネント。
13.
今回のDSL キャンペーン商品の割引: 条件: カート.キャンペーン商品を含む() 割引: カート.商品合計()
* 0.1 全体はYAMLで記述 「条件」と「割引」に ExpressionLanguageを 使う
14.
Cartクラス ... public function 送料() { return
$this->getShippingCost(); } public function キャンペーン商品を含む () { return $this->existsCampaignProduct(); } public function 商品合計() { return $this->getProductTotalPrice(); } ...
15.
ExpressionLanguageを使う部分(抜粋) $el = new
ExpressionLanguage(); foreach ($config as $name => $values) { $isSatisfied = $el->evaluate($values['条件'], ['カート' => $cart]); if (! $isSatisfied) continue; $price = $el->evaluate($values['割引'], ['カート' => $cart]); $cart->addDiscount(new Discount($name, $price)); }
16.
デモ
17.
オブジェクト指向で実装すると・・・ 条件・割引をインターフェイスで抽象化したり。 DIコンテナで注入できるようにしたり。 などなど。 いずれにしても条件・割引のルールが変更されるたびに実 装が必要になる。
18.
DSLのデメリット 設計が難しい。 ・問題領域の特定 ・想定外の要求に対してどう対応するか DSLを使うかどうかに関わらず、難しい問題なので、設計力 が重要になってくる。
19.
まとめ ● DSLは小さな問題領域にフォーカスしたものである。 ● PHPでもライブラリなどを利用することによってDSLを定義 できる。 ●
DSLの設計は難しいがメリットも大きい。 ● コードで実装することだけが解決策ではない。
20.
参考 サンプル: https://github.com/matsufuji/phpck2017-dsl ExpressionLanguage: http://symfony.com/doc/current/components/expression_ language.html
Download