Data Context Interaction is recently invented programming paradigm, which aims at separating behaviour from data model, by extracting interactions into roles, which can be played by objects in various contexts.
This presentation is going to give brief introduction to DCI, propose ways to implement roles' injection in Ruby and discuss how DCI could be used to supplement Rails' MVC paradigm.
5. Elf object would...
Reduce victim’s health points to 0.
Add some experience to itself.
Log frag on leader board.
Actually it should check who gets killed.
Or... maybe we should have fight before
deciding who dies.
6. Lets leave the elf
object alone
He doesn’t need to know how killing is
implemented in system.
Lets implement activities (behaviours) for our
characters.
11. MVC and DCI
(how can it play with Rails)
DCI can be complementary to MVC
Controller loads adequate objects and
initiates context with them
Context injects roles to objects and let them
to play
16. How to implement
1. Decoration: #extend
Cons:
There is no
#unextend method
Tends to be slow
on some Rubies
17. How to implement
2. Presenter
Pros:
Object encapsulation
Cons:
Object encapsulation
(however object still
accessible via
#object method)
18. How to implement
3. Delegation
Cons:
Uses
#method_missing to
implement delegation
19. How to implement
4. Delegate Class
It creates delegation methods for instance methods of delegated
class.
Cons:
Static delegation
relationship
Role is a class
instead of module