Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
HEAD FIRST
   DSL
• DSL is Everywhere
• DSL Overview
• What is DSL?
• Why Use a DSL?
• DSL and DDD
DSL is Everywhere
2001   2002   2003   2004   2005   2006   2007   2008   2009   2010
DSL Overview
DSL Exec Overview




            http://martinfowler.com/dslwip/ImplementingDsls.html
•
•   2

•
Semantic Model (SM)




              http://martinfowler.com/dslwip/Intro.html
Semantic Model (Class)




                http://martinfowler.com/dslwip/Intro.html
Semantic Model (Java)
class State...
  private String name;
  private List<Command> actions = new ArrayList<Command>();
  ...
Client Code
Event doorClosed = new Event("doorClosed", "D1CL");
Event drawOpened = new Event("drawOpened", "D2OP");
Event ...
DSL (XML)
<stateMachine start = "idle">
    <event name="doorClosed" code="D1CL"/>
    <event name="drawOpened" code="D2OP...
DSL (Ruby)
event   :doorClosed, "D1CL"
event   :drawOpened, "D2OP"
event   :lightOn, "L1ON"
event   :doorOpened, "D1OP"
ev...
What is DSL?
3

•   DSL

•   DSL

•
DSL


DSL   (   )
DSL (XML)
<stateMachine start = "idle">
    <event name="doorClosed" code="D1CL"/>
    <event name="drawOpened" code="D2OP...
DSL


DSL   (   )
DSL (Ruby)
event   :doorClosed, "D1CL"
event   :drawOpened, "D2OP"
event   :lightOn, "L1ON"
event   :doorOpened, "D1OP"
ev...
http://martinfowler.com/articles/languageWorkbench.html
http://martinfowler.com/dslwip/Intro.html
DSL
http://www.flickr.com/photos/bobloo17/188697388/
http://www.flickr.com/photos/typedow/516148822/
http://www.flickr.com/photos/ocean_of_stars/3064512601/
http://www.flickr.com/photos/naps/1071881251/
• Active Record
•R
•
Why Use a DSL
Fowler-DSL
http://martinfowler.com/dslwip/Intro.html
DSL
http://www.flickr.com/photos/nicholasngkw/2935730640/
DSL
4
http://www.flickr.com/photos/blackbutterfly/3051019058/
http://www.flickr.com/photos/winton/3915959349/
http://www.flickr.com/photos/argonne/4244642347/
• State Machine
• Dependency Network
• Decision Table
• Production Rule System
DSL
•
•
•
• DSL
•
DSL and DDD
• DSL

• DSL
HEAD FIRST DSL
HEAD FIRST DSL
HEAD FIRST DSL
Upcoming SlideShare
Loading in …5
×

HEAD FIRST DSL

2,122 views

Published on

名前は適当につけました。HEAD FIRSTシリーズとは何も関係ありません。スタイルすら関係ありません。

Published in: Design
  • Be the first to comment

HEAD FIRST DSL

  1. 1. HEAD FIRST DSL
  2. 2. • DSL is Everywhere • DSL Overview • What is DSL? • Why Use a DSL? • DSL and DDD
  3. 3. DSL is Everywhere
  4. 4. 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010
  5. 5. DSL Overview
  6. 6. DSL Exec Overview http://martinfowler.com/dslwip/ImplementingDsls.html
  7. 7. • • 2 •
  8. 8. Semantic Model (SM) http://martinfowler.com/dslwip/Intro.html
  9. 9. Semantic Model (Class) http://martinfowler.com/dslwip/Intro.html
  10. 10. Semantic Model (Java) class State... private String name; private List<Command> actions = new ArrayList<Command>(); private Map<String, Transition> transitions = new HashMap<String, Transition>(); public void addTransition(Event event, State targetState) { transitions.put(event.getCode(), new Transition(this, event, targetState)); } class Transition... private final State source, target; private final Event trigger; public Transition(State source, Event trigger, State target) { this.source = source; this.target = target; this.trigger = trigger; } public State getSource() {return source;} public State getTarget() {return target;} public Event getTrigger() {return trigger;} public String getEventCode() {return trigger.getCode();} http://martinfowler.com/dslwip/Intro.html
  11. 11. Client Code Event doorClosed = new Event("doorClosed", "D1CL"); Event drawOpened = new Event("drawOpened", "D2OP"); Event lightOn = new Event("lightOn", "L1ON"); Event doorOpened = new Event("doorOpened", "D1OP"); Event panelClosed = new Event("panelClosed", "PNCL"); Command unlockPanelCmd = new Command("unlockPanel", "PNUL"); Command lockPanelCmd = new Command("lockPanel", "PNLK"); Command lockDoorCmd = new Command("lockDoor", "D1LK"); Command unlockDoorCmd = new Command("unlockDoor", "D1UL"); State idle = new State("idle"); State activeState = new State("active"); State waitingForLightState = new State("waitingForLight"); State waitingForDrawState = new State("waitingForDraw"); State unlockedPanelState = new State("unlockedPanel"); StateMachine machine = new StateMachine(idle); idle.addTransition(doorClosed, activeState); idle.addAction(unlockDoorCmd); http://martinfowler.com/dslwip/Intro.html
  12. 12. DSL (XML) <stateMachine start = "idle"> <event name="doorClosed" code="D1CL"/> <event name="drawOpened" code="D2OP"/> <event name="lightOn" code="L1ON"/> <event name="doorOpened" code="D1OP"/> <event name="panelClosed" code="PNCL"/> <command name="unlockPanel" code="PNUL"/> <command name="lockPanel" code="PNLK"/> <command name="lockDoor" code="D1LK"/> <command name="unlockDoor" code="D1UL"/> <state name="idle"> <transition event="doorClosed" target="active"/> <action command="unlockDoor"/> <action command="lockPanel"/> </state> <state name="active"> <transition event="drawOpened" target="waitingForLight"/> <transition event="lightOn" target="waitingForDraw"/> </state> http://martinfowler.com/dslwip/Intro.html
  13. 13. DSL (Ruby) event :doorClosed, "D1CL" event :drawOpened, "D2OP" event :lightOn, "L1ON" event :doorOpened, "D1OP" event :panelClosed, "PNCL" command :unlockPanel, "PNUL" command :lockPanel, "PNLK" command :lockDoor, "D1LK" command :unlockDoor, "D1UL" resetEvents :doorOpened state :idle do actions :unlockDoor, :lockPanel transitions :doorClosed => :active end state :active do transitions :drawOpened => :waitingForLight, :lightOn => :waitingForDraw end http://martinfowler.com/dslwip/Intro.html
  14. 14. What is DSL?
  15. 15. 3 • DSL • DSL •
  16. 16. DSL DSL ( )
  17. 17. DSL (XML) <stateMachine start = "idle"> <event name="doorClosed" code="D1CL"/> <event name="drawOpened" code="D2OP"/> <event name="lightOn" code="L1ON"/> <event name="doorOpened" code="D1OP"/> <event name="panelClosed" code="PNCL"/> <command name="unlockPanel" code="PNUL"/> <command name="lockPanel" code="PNLK"/> <command name="lockDoor" code="D1LK"/> <command name="unlockDoor" code="D1UL"/> <state name="idle"> <transition event="doorClosed" target="active"/> <action command="unlockDoor"/> <action command="lockPanel"/> </state> <state name="active"> <transition event="drawOpened" target="waitingForLight"/> <transition event="lightOn" target="waitingForDraw"/> </state> http://martinfowler.com/dslwip/Intro.html
  18. 18. DSL DSL ( )
  19. 19. DSL (Ruby) event :doorClosed, "D1CL" event :drawOpened, "D2OP" event :lightOn, "L1ON" event :doorOpened, "D1OP" event :panelClosed, "PNCL" command :unlockPanel, "PNUL" command :lockPanel, "PNLK" command :lockDoor, "D1LK" command :unlockDoor, "D1UL" resetEvents :doorOpened state :idle do actions :unlockDoor, :lockPanel transitions :doorClosed => :active end state :active do transitions :drawOpened => :waitingForLight, :lightOn => :waitingForDraw end http://martinfowler.com/dslwip/Intro.html
  20. 20. http://martinfowler.com/articles/languageWorkbench.html
  21. 21. http://martinfowler.com/dslwip/Intro.html
  22. 22. DSL
  23. 23. http://www.flickr.com/photos/bobloo17/188697388/
  24. 24. http://www.flickr.com/photos/typedow/516148822/
  25. 25. http://www.flickr.com/photos/ocean_of_stars/3064512601/
  26. 26. http://www.flickr.com/photos/naps/1071881251/
  27. 27. • Active Record •R •
  28. 28. Why Use a DSL
  29. 29. Fowler-DSL
  30. 30. http://martinfowler.com/dslwip/Intro.html
  31. 31. DSL
  32. 32. http://www.flickr.com/photos/nicholasngkw/2935730640/
  33. 33. DSL
  34. 34. 4
  35. 35. http://www.flickr.com/photos/blackbutterfly/3051019058/
  36. 36. http://www.flickr.com/photos/winton/3915959349/
  37. 37. http://www.flickr.com/photos/argonne/4244642347/
  38. 38. • State Machine • Dependency Network • Decision Table • Production Rule System
  39. 39. DSL • • • • DSL •
  40. 40. DSL and DDD
  41. 41. • DSL • DSL

×