Data Context Interaction - What is it good for?


Published on

Slides for a presentation about Data Context Interaction for the Stockholm Ruby User Group meetup

Published in: Technology, Business
  • Be the first to comment

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Data Context Interaction - What is it good for?

  1. 1. Data Context Interaction What is it good for? Markus Nordin @mnordin
  2. 2. DisclaimerI will for the next 30 minutes talk smack about MVC But i secretly <3 MVC
  3. 3. History of DCITrygve Reenskaugs ideas about role based modeling in early 2000 (same guy who invented MVC in the late seventies) Working design model in 2006 Working prototype in mid 2008 Complement to MVC
  4. 4. Why DCI? MVC fails to capture behaviour Theres no apparent place to put interactions (exception: simple actions that involves a single object) Model should represent things Things should be stableNatural difference between what an object is and what it does. Why not in the code?
  5. 5. Goals with DCI Giving system behaviour first class status Cleanly separate code for rapidly changingbehavior from code for slowly changing domain knowledgeObject style of thinking that is close to peoples mental models rather than class style
  6. 6. Data What the system is Closely corresponds to the ModelReflects the domain structure rather than behaviour
  7. 7. Context Context is a class (instance) which enacts one (or more) use cases Instantiated by a user (controller) action Mixes in participating objects with RolesThe context is responsible for acting out the use case
  8. 8. Interaction What the system does Methods in role modulesImplemented by mixing in objects with Roles in a given Context or use case
  9. 9. Executing DCIController action starts a use case by instansiating a context class The context finds (or creates) the objects that are participating in the use case The context mixes in all the roles needed into the objects The context invokes the role methods on the objects and starts the use case enactment
  10. 10. Money transfer exampleBank - send money to another account SendMoneyContext account accountSourceAccount DestinationAccount send(amount) verify(amount) deposit(amount)
  11. 11. My implementation Training app Attend a training event UserAttendsEventContext user eventAttendingRole PublicEventRoleattends(event) attend_on_google(user)
  12. 12. What is it good for?Kind of awkward to deal with context instances - bad implementation? Class methods belonging to roles or object? Simple console usage must also follow the context Easy to find specific methods (if used consistently) Fat models go on crash diet! Easy to maintain Easy to follow an entire use case
  13. 13. Questions?Do we need DCI?
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.