Upload
atsuhiro-kubo
View
4.393
Download
0
Embed Size (px)
Citation preview
2013/6/1(土) PHPカンファレンス関西2013
意図を表現するプログラミング
PHPメンターズ久保敦啓 (KUBO Atsuhiro)
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
久保敦啓 (KUBO Atsuhiro)● Twitter @iteman● GitHub https://github.com/iteman● PHPメンターズ● Piece Framework● 日本Symfonyユーザー会● 関西IT勉強宴会
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
PHPメンターズ● PHPプログラマーを対象とするサービス
– トレーニング、技術サポート、メンタリング– プログラミング道場
● メンター– 久保敦啓 @iteman– 後藤秀宣 @hidenorigoto
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
PHPメンターズ● Twitter @phpmentors● GitHub https://github.com/phpmentors-jp● Webサイト・ブログ
http://phpmentors.jp/
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
Piece Framework● PHPフレームワーク、ツール
– MakeGood– Stagehand_TestRunner
● オープンソースソフトウェア● Piece Project
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
Piece Framework● Twitter @piece_framework● GitHub https://github.com/piece● Webサイト
http://piece-framework.com/
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
過去の活動を振り返る
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
2003年● 2002-12-27 PHP 4.3.0● 2003-02-29 Net_UserAgent_Mobile 0.1
– 携帯キャリア判別ライブラリ– PEAR http://pear.php.net/
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
Net_UserAgent_Mobile
<?php…require_once 'Net/UserAgent/Mobile.php';…$mobile = &Net_UserAgent_Mobile::factory();if ($mobile->isDoCoMo()) { …} elseif ($mobile->isSoftBank()) { …
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
2004年● 7月 第1回PHP関西セミナー
– 久保によるMojavi 2 + Smartyの解説
● 7月 PHP 5.0.0– Zend Engine 2、新しいオブジェクトモデル
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
2005年● 7月 PHP 4.4.0● 11月 PHP 5.1.0
– PDO
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
2006年● 1月 Maple祭り
– 高橋邦彦さん @kunit さんによるWebアプリケーションフレームワークMapleの勉強会
● 4月 Stagehand_TestRunner 0.3.0– コマンドラインテストランナー
● 8月 Piece_Unity 0.6.0– Webアプリケーションフレームワーク
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
2006年● 10月 第3回Piece Framework勉強会
– 久保「Piece Frameworkの概要」
● 11月 PHP 5.2.0● 11月 関西オープンソース2006
– 企業へのOSSの導入・活用、Linux、Samba– 久保「Piece Framework を体験する」
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
ページフロー定義(Eclipse)
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
ページフロー定義(YAML)
...viewState: - name: Input view: Input activity: method: onInput transition: - event: next nextState: Validation...
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
2007年● 3月 Piece_ORM 0.1.0
– SQLマッパー
● 3月 第8回PHP関西セミナー– 久保「Piece_ORMの概要」
● 7月 オープンソースカンファレンス2007 Kansai– 仮想化技術(Xen)、MySQL、Ruby on Rails– 久保「Piece FrameworkによるセキュアなWebアプリケーション
の開発」
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
2007年● 11月 関西オープンソース2007
– MySQL、Ruby– 久保「Piece Framework入門」
● 12月 Piece Network 1– 高木正弘さん「PHPマニュアルの読み方」– 関山隆介さん「SPL入門」
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
SQLマッピング(Piece_ORM)
...method: - name: findById query: SELECT * FROM user WHERE id = $id...
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
2008年● 8月 PHP 4.4.9
– PHP 4の最後のリリース● 11月 関西オープンソース2008
– 伊藤直也さん講演会、Memcached、関西Ruby会議、チケット駆動開発
– 高橋邦彦さん「設計勉強会@関西」– 久保「Piece Frameworkの概要」
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
2009年● 9月 PHP 5.3.0
– 名前空間、遅延静的束縛、goto、無名関数(クロージャ)
● 11月 関西オープンソース2009– OpenSocial、Ruby、アジャイル、スマートフォン– 久保、松藤「Eclipse + PHP + TDD = MakeGood!」
● 11月 MakeGood 0.1.0– Eclipse PDT向けテストランナー
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
MakeGood
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
2010年● 2月 XP祭り関西2010
– 久保「Tools for Doing Test Driven Development in PHP」● 3月 オープンソースカンファレンス2010 Kansai@Kobe● 4月 オープンソースカンファレンス2010 Kansai@Kyoto
– WordPress、concrete5、Drupal、EC-CUBE、Magento– HTML5、クラウド関連 – 久保、松藤「Eclipse PDT + MakeGood による PHP コードのテスト」
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
2010年● 8月 第1回関西IT勉強宴会
– 久保「GitHubの使い方」
● 11月 関西オープンソース2010– Ruby、スマートフォン、HTML5– 渡辺幸三さん「刮目せよ!モデリング技術がもたらすオープ
ンソース業務システム」– 久保「フレームワーク・ツールによるPHPプログラムの自動テ
スト」
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
2011年● 7月 第1回関西PHP勉強会
– テーマ「PHP におけるテスト」– 久保「継続的テスト入門」
● 10月 PHP Matsuri 2011– 久保「PHPUnitでテストを始めよう」
● 11月 関西オープンソース2011– 東日本大震災、クラウド、Ruby、テスト駆動開発– 久保「継続的テストランナーMakeGood入門」
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
2012年● 3月 PHP 5.4.0
– トレイト、ビルトインウェブサーバー
● 4月 第3回関西PHP勉強会– テーマ「Symfony2マスターが直接手ほどき!アプ
リケーション開発実況観戦」– 久保「Symfonyによるソフトウェア開発入門」
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
意図Intention
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
“意図的な記述は、何が必要なのかを直接かつ明確に示し、余計ながらくたや不要な実装の詳細を避けます。これらは、理解しやすさ、分析しやすさ、修正しやすさ、保守のしやすさなどの、良いコードが持つすべての属性を備えています。ドメインに固有な表記法により、意図性を達成します。“
— ジェネレーティブプログラミング
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
<?php$link = mysql_connect('localhost', 'myuser', 'mypassword');mysql_select_db('blog_db', $link);$result = mysql_query('SELECT id, title FROM post', $link);?><html> ... <ul> <?php while ($row = mysql_fetch_assoc($result)): ?> <li> <a href="/show.php?id=<?php echo $row['id'] ?>"> <?php echo $row['title'] ?> </a> </li> <?php endwhile; ?> ...</html><?phpmysql_close($link);
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
「もつれた」意図● (暗黙の)ルーティング● データベースアクセス● ユーザーインターフェイス
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
<?php...class BlogController extends Controller{ public function listAction() { $posts = $this->get('doctrine')->getManager() ->createQuery('SELECT p FROM AcmeBlogBundle:Post p') ->execute();
return $this->render( 'AcmeBlogBundle:Blog:list.html.php', array('posts' => $posts) ); } ...
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
blog_list: path: /blog defaults: { _controller: AcmeBlogBundle:Blog:list }
blog_show: path: /blog/show/{id} defaults: { _controller: AcmeBlogBundle:Blog:show }
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
<?phprequire_once __DIR__.'/../app/bootstrap.php';require_once __DIR__.'/../app/AppKernel.php';
use Symfony\Component\HttpFoundation\Request;
$kernel = new AppKernel('prod', false);$kernel->handle(Request::createFromGlobals())->send();
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
{% extends "::layout.html.twig" %}
{% block title %}List of Posts{% endblock %}
{% block body %} <h1>List of Posts</h1> <ul> {% for post in posts %} <li> <a href="{{ path('blog_show', {'id': post.id}) }}"> {{ post.title }} </a> </li> {% endfor %} </ul>{% endblock %}
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
モデルビューコントローラー
コントローラー
モデル
ビュー
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
レイヤー化アーキテクチャー
ドメイン
アプリケーション
ユーザーインターフェイス
インフラストラクチャ
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
「もつれた」意図をほぐす道具● アーキテクチャーパターン● デザインパターン● 各種プログラミングパラダイム● プログラミング言語、フレームワーク、ライブ
ラリ● ドメイン特化言語
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
グラフィカルDSLによる意図の表現
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
テキストDSLによる意図の表現
...viewState: - name: Input view: Input activity: method: onInput transition: - event: next nextState: Validation...
Copyright (c) 2013 KUBO Atsuhiro <[email protected]>, All rights reserved.
参考● Symfony2 versus Flat PHP (current) - Symfony,
http://symfony.com/doc/current/book/from_flat_php_to_symfony2.html● Wikipedia contributors. "PHP." Wikipedia, The Free Encyclopedia.
Wikipedia, The Free Encyclopedia, 29 May. 2013. Web. 31 May. 2013.● エリック・エヴァンス「エリック・エヴァンスのドメイン駆動設計」、翔泳社、
2011年。● クシシュトフ・チャルネッキ、ウールリシュ・W・アイセンアッカ「ジェネレー
ティブプログラミング」、翔泳社、2008年。● マーチン・ファウラー「エンタープライズ アプリケーションアーキテクチャパ
ターン」、翔泳社、2005年。