Model on Grails

56
Model On Grails ~ DCIアーキテクチャへの道すじ ~ G * Work!op 2010.11.09 和智 右桂 @digitalsoul0124

description

第12回 G* ワークショップ

Transcript of Model on Grails

Page 1: Model on Grails

Model On Grails~ DCIアーキテクチャへの道すじ ~

G * Work!op 2010.11.09

和智 右桂 @digitalsoul0124

Page 2: Model on Grails

和智 右桂

JavaEE勉強会 所属

InfoQ Japanでときどき翻訳

Yukei Wachi

@digitalsoul0124Digital Romanticism

http://d.hatena.ne.jp/digitalsoul

ネコ好き

Photo by @digitalsoul0124 All rights reserved.

思想系プログラマ

Page 3: Model on Grails

Photo by @digitalsoul0124 All rights reserved.

アジェンダ•導入•先駆者たちが遺したもの•オブジェクト指向の死角•DCIアーキテクチャ•サンプル

スライド中で使用されている画像について、その著作権の全部または一部は、 クレジットに示した著者によって保留されています。

また、スライド中で使用されている画像の著者、およびそこに登場する人物は、スライドの内容とは関係ありません。

Page 4: Model on Grails

導入

Introduction

Page 5: Model on Grails

DCIアーキテクチャSun Rise http://www.flickr.com/photos/umairmohsin/2068422156/ by Umair Mohsin

Page 6: Model on Grails

Jim Coplien and Trygve Reenskaug

Jim Coplien and Trygve Reenskaug http://www.flickr.com/photos/lassekoskela/2449622395/ by lassekoskela All rights reserved.

Page 7: Model on Grails

モデル・ビュー・コントローラ - Trygve Reeenskaughttp://d.hatena.ne.jp/digitalsoul/20100913/1284330448

組織パターン - James Coplienhttp://d.hatena.ne.jp/digitalsoul/20100913/1284330448

Page 8: Model on Grails

先駆者たちが遺したものHe"ta#

Object O"ented

Page 9: Model on Grails

1963

Doug EnglebartLet's play cat and mouse http://www.flickr.com/photos/sondyaustin/2238102441/ by Sandy Austin

マウスの発明

Page 10: Model on Grails

1972

Alan KayAlan Kay and the prototype of Dynabook, pt. 5 http://www.flickr.com/photos/mwichary/3010032738/ by Marcin Wichary

ダイナブック構想

Page 11: Model on Grails

1979

Trygve Reenskaug

Controller

View

Model

MVCの提唱

Page 12: Model on Grails

コンピュータとは

Ahchan and iPad http://www.flickr.com/photos/jetalone/4694268229/ by jetalone

人間精神を拡張したもの

Page 13: Model on Grails

グラフィカルユーザインタフェース と

MCD_Detailed_machine http://www.flickr.com/photos/31274959@N08/4968548272/ by Siemens PLM Software

GUI

Object-o"ented langua#オブジェクト指向言語

Page 14: Model on Grails

メンタルモデルを写し取るもの出典:http://heim.ifi.uio.no/~trygver/themes/mvc/mvc-index.html by Trygve M. H. Reenskaug

Mental ModelMVCとは

Page 15: Model on Grails

精神の構造を映し出すもの

モデルとは世界のとらえ方

Boston Atheneum-Astrolabe Light Fixture by Phil Manker http://www.flickr.com/photos/philmanker/3358357560/ by Phil Manker

Page 16: Model on Grails

インタフェースを通じて

モデルを操作するH2O Kansas / Installation view http://www.flickr.com/photos/topekalibrary/4598238661/ by Topeka & Shawnee County Public Library

Interface

Page 17: Model on Grails

直接操作メタファ

Direct manipulation metaphor

connection http://www.flickr.com/photos/mistoacrilico/4982964217/ by MistoAcrilico

Page 18: Model on Grails

構造によって思考をとらえる

Para%gm

NYC - MoMA: Design and the Elastic Mind - Emergent Surface http://www.flickr.com/photos/wallyg/2373587283/ by wallyg

Page 19: Model on Grails

オブジェクト指向の死角

Blind side

Page 20: Model on Grails

Readability

Red pen stuck between the pages of a book http://www.flickr.com/photos/horiavarlan/4289811229/ by Horia Varlan

 via “The Common Sense of Object Orientated Programming”

“システムがどう機能するかということについて、コードが全てを明らかにしているわけではない。”

- Design Patterns

Page 21: Model on Grails

実行時の構成

コンパイル時の構成

Photo by @digitalsoul0124 All rights reserved.四尺玉 4-shaku dama http://www.flickr.com/photos/mmqb01/3644955925/ by alde

Page 22: Model on Grails

なぜ?

Weird and lost... http://www.flickr.com/photos/h-k-d/4806183950/ by h.koppdelaney

何が問題なのか?

Page 23: Model on Grails

思考 と 行動

構造 とふるまい

ikea hack cat tower http://www.flickr.com/photos/nrabinowitz/4416084196/ by nwrabinowitz

&inking

doing

Page 24: Model on Grails

構造をとらえ、表現することはできた

しかし...Modern Structures http://www.flickr.com/photos/ourcloset/4781534198/ by The Photography Factory

Structure

Page 25: Model on Grails

全体としてのふるまいをとらえることができなかった

Time Machine Clockwork http://www.flickr.com/photos/7969902@N07/476909988/in/photostream/ by Pierre J.

Behavi'r

Page 26: Model on Grails

その結果...

Page 27: Model on Grails

断片化されたアルゴリズムpuzzling http://www.flickr.com/photos/torisan3500/3837736087/ by torisan3500

Page 28: Model on Grails

継承による可変性の担保

Billiard Ball Blur http://www.flickr.com/photos/31572898@N06/4304781964/ by JAS_photo

Page 29: Model on Grails

DCIアーキテクチャ

Data

Interaction

Context

Page 30: Model on Grails

“全てがクラス”

ではなかったのかも?lego_relativity http://www.flickr.com/photos/skip/42288914/in/photostream/ by Skip The Budgie

Page 31: Model on Grails

思考 と 行動

異なる位相 異なる境界ML3K Series: 10 of 17 http://www.flickr.com/photos/jefharris/464574462/ by Jef Harris

Page 32: Model on Grails

構造を表現するのはデータ

Etcetera Domain Class Diagram http://www.flickr.com/photos/benkreeger/4356876712/ by Ben and Laura Kreeger

Data

Page 33: Model on Grails

ふるまいについて考える時...

Behavi'r

Page 34: Model on Grails

ペルソナ4 http://www.flickr.com/photos/hobby_blog/3340775781/ by hobby_blog

ペルソナ4

Role

僕らはクラスよりもロールのことを考えている

Page 35: Model on Grails

データはロールを演じるための能力を持つ

Fitness Model 1 http://www.flickr.com/photos/spunkinator/3474090193/ by ★ spunkinator

Capacity

Page 36: Model on Grails

データとロールを紐づけるもの

それが...Hands & Rings on Bible http://www.flickr.com/photos/gregkendallball/552440766/ by gregkendallball

Page 37: Model on Grails

コンテキスト

マクロスfrontier http://www.flickr.com/photos/hobby_blog/3340831827 by hobby_blog

マクロス frontierContext

Page 38: Model on Grails

ata

ontext

nteractionD wiDe - zinken welanD http://www.flickr.com/photos/evaekeblad/2131712842/ by Eva the Weaver

c http://www.flickr.com/photos/toofarnorth/1664666328/ by TooFarNorthSTAR WARS http://www.flickr.com/photos/hobby_blog/138259452/ by hobby_blog

Page 39: Model on Grails

課題は...

Challen#

Page 40: Model on Grails

コンパイル時の分離

実行時の融合Rings and Things http://www.flickr.com/photos/goldiekatsu/4768306645/ by goldiekatsu

Page 41: Model on Grails

Trait

Groovyならmixin.

public class RoleUtil {

static <T> T assign(assignee, Class<T> role) {

assignee.metaClass.mixin role

assignee.asType role

}

}

Page 42: Model on Grails

サンプル

Sample

Page 43: Model on Grails

給与計算システム

Mixed Cash http://www.flickr.com/photos/crazyneighborlady/415534472/ by stopnlook

Page 44: Model on Grails

仕様

基本は時給制

時給は従業員ごとに定められている

商品が売れれば、値段に応じたインセンティブが付く

インセンティブの割合は従業員ランクによって決まる

SENIOR : 3%

MEMBER : 2%

NOVICE : 1%

給与計算は月単位で行う

Page 45: Model on Grails

構造

従業員

ランク

売り上げ票タイムカード

商品

Data

Page 46: Model on Grails

HQLSELECT

sum(salesReceipt.item.price), salesReceipt.employee.id

FROM

SalesReceipt salesReceipt

WHERE

date >= :startOfMonth and :endOfMonth >= date

GROUP BY

salesReceipt.employee.id

Page 47: Model on Grails

データにロールを割り当てる

レコード1

○○合計取得

レコード2レコード3レコード4レコード5

Page 48: Model on Grails

ふるまい(給与計算)

給与計算給与計算サービス

時給合計

売り上げ合計

Role 従業員ごとに給与計算を行う

インセンティブ計算

Page 49: Model on Grails

Demoデモ

Page 50: Model on Grails

最後に

One more &ing...

Page 51: Model on Grails

単なるギミックではない

Page 52: Model on Grails

安定性と可変性

構造は安定し、ふるまいは変化する

清水寺 Kiyomizu Dera http://www.flickr.com/photos/chiszeo/4510636080/ by Chi (in Japan)

Page 53: Model on Grails

システムレベルのふるまいを考える

全体観flock of birds http://www.flickr.com/photos/marfis75/3279307888/ by marfis75

Page 54: Model on Grails

洞察

メンタルモデルとの整合性

"Girl before a mirror" by Picasso, MoMA http://www.flickr.com/photos/25730976@N06/3908069402/ by conxa.roda

Page 55: Model on Grails

ソフトウェアは一編の小説である

緻密に構築され美しく語られなければならない

ご質問はありますか?

Page 56: Model on Grails

ありがとうございました!Photo by @digitalsoul0124 All rights reserved.