SlideShare a Scribd company logo
DCI
Data Context Interaction
About me:
Dawid Sklodowski
Works at @HouseTrip (we are hiring)
DCI: Why?
Separating behaviour from data model
Making behaviour first-class citizen
Supporting style of thinking closer to
people’s mental model
DCI: Who?
Invented by Trygve Reenskaug
Current formulation mostly by Trygve
Reenskaug and Jim Coplien
In 2009
Example
Ninja Elf kills Pirate Dwarf
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.
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.
Data
Data
Data is “what system is”.
Objects which contain methods to change
their state.
No interaction with other objects
Context
Entry point
Injects roles
Knows who does what
Interaction
Interaction is “what system does”.
Implemented as roles which are played by
objects in run-time
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
MVC and DCI
ControllerUser
Context
Model
View
Rolesdata object
Use Case: Context
Sample Role
How to implement?
with Ruby
Problem: Role Injection
How to implement
1. Decoration: #extend
Cons:
There is no
#unextend method
Tends to be slow
on some Rubies
How to implement
2. Presenter
Pros:
Object encapsulation
Cons:
Object encapsulation
(however object still
accessible via
#object method)
How to implement
3. Delegation
Cons:
Uses
#method_missing to
implement delegation
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
How to implement
Dynamic DelegateClass
Dynamic delegation relationship, but isn’t that slow?
How to implement
Any pattern can be implemented in dynamic way
Performance comparison
Implementation
Performance
comparison
Results
How to implement
DelegateClass: Performance Wise
Caching anonymous role classes
Other pros
We can chain roles on object
We don’t pollute original object with role
leftovers (unlike #extend)
Summary
Separates behaviour from data model
Can play nicely with Rails and MVC
No straightforward way to implement with
Ruby
But it is doable
Thank You
github.com/dawid-sklodowski
onceuponaline.info
@DawidSklodowski

More Related Content

PPTX
Generative AI Masterclass - Model Risk Management.pptx
PDF
Fraud Detection with Graphs at the Danish Business Authority
PPTX
The Evolution of Data Architecture
PDF
Exploring BigData with Google BigQuery
PDF
AI-Powered Streaming Analytics for Real-Time Customer Experience
PDF
ChatGPT Prompt Engineering
DOCX
Tableau Course syllabus
PDF
Data Mesh in Practice - How Europe's Leading Online Platform for Fashion Goes...
Generative AI Masterclass - Model Risk Management.pptx
Fraud Detection with Graphs at the Danish Business Authority
The Evolution of Data Architecture
Exploring BigData with Google BigQuery
AI-Powered Streaming Analytics for Real-Time Customer Experience
ChatGPT Prompt Engineering
Tableau Course syllabus
Data Mesh in Practice - How Europe's Leading Online Platform for Fashion Goes...

What's hot (20)

PDF
AIOps: Anomalies Detection of Distributed Traces
PPTX
Prowess_B2B-EDI_Anypoint Partner Manager_Final.pptx
PDF
Using pySpark with Google Colab & Spark 3.0 preview
PPTX
Introduction for ChatGPT - Primer to Dummies
PPTX
Data centric business and knowledge graph trends
PDF
Graph based data models
PPT
RDF and OWL
PDF
LDM Webinar: Data Modeling & Metadata Management
PPTX
Knowledge graphs for knowing more and knowing for sure
PDF
LanGCHAIN Framework
PDF
GCP-pde.pdf
PDF
Neo4j Training Modeling
PDF
Understanding GenAI/LLM and What is Google Offering - Felix Goh
PDF
Big Query Basics
PDF
Adobe analytics - playbook
PDF
Data Governance Roles as the Backbone of Your Program
PDF
All in AI: LLM Landscape & RAG in 2024 with Mark Ryan (Google) & Jerry Liu (L...
PDF
ChatGPT webinar slides
PPTX
Databricks Platform.pptx
PDF
Data management best practices - infographic
AIOps: Anomalies Detection of Distributed Traces
Prowess_B2B-EDI_Anypoint Partner Manager_Final.pptx
Using pySpark with Google Colab & Spark 3.0 preview
Introduction for ChatGPT - Primer to Dummies
Data centric business and knowledge graph trends
Graph based data models
RDF and OWL
LDM Webinar: Data Modeling & Metadata Management
Knowledge graphs for knowing more and knowing for sure
LanGCHAIN Framework
GCP-pde.pdf
Neo4j Training Modeling
Understanding GenAI/LLM and What is Google Offering - Felix Goh
Big Query Basics
Adobe analytics - playbook
Data Governance Roles as the Backbone of Your Program
All in AI: LLM Landscape & RAG in 2024 with Mark Ryan (Google) & Jerry Liu (L...
ChatGPT webinar slides
Databricks Platform.pptx
Data management best practices - infographic
Ad

Similar to DCI with Ruby and Rails (20)

PDF
Data Context Interaction - What is it good for?
PPTX
DCI - ANUG 24th November 2010
PPTX
DCI ANUG - 24th November 2010
PPTX
Domain Driven Design
PDF
Domain driven design: a gentle introduction
PPT
DCI with groovy
PPTX
Marco Mancuso - Data Context Interaction
PPTX
Software Development: Beyond Training wheels
PDF
STOP! Use case time!
PPTX
DCI
PPTX
Domain Driven Design
PPTX
DFD and Class diagram
PPTX
Software Design Trilogy Part I - Responsibility Driven Design for Rubyists
PPTX
Crafted Design - GeeCON 2014
PPTX
Pattern oriented architecture for web based architecture
PDF
Beyond MVC: from Model to Domain
PPTX
Crafted Design - Sandro Mancuso
PPTX
DCI @ XING
PPTX
Creating a shared understanding through Story Mapping, Spec by Example, & Dom...
PPTX
Crafted Design - ITAKE 2014
Data Context Interaction - What is it good for?
DCI - ANUG 24th November 2010
DCI ANUG - 24th November 2010
Domain Driven Design
Domain driven design: a gentle introduction
DCI with groovy
Marco Mancuso - Data Context Interaction
Software Development: Beyond Training wheels
STOP! Use case time!
DCI
Domain Driven Design
DFD and Class diagram
Software Design Trilogy Part I - Responsibility Driven Design for Rubyists
Crafted Design - GeeCON 2014
Pattern oriented architecture for web based architecture
Beyond MVC: from Model to Domain
Crafted Design - Sandro Mancuso
DCI @ XING
Creating a shared understanding through Story Mapping, Spec by Example, & Dom...
Crafted Design - ITAKE 2014
Ad

Recently uploaded (20)

PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Tartificialntelligence_presentation.pptx
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PDF
project resource management chapter-09.pdf
PPTX
Chapter 5: Probability Theory and Statistics
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
Mushroom cultivation and it's methods.pdf
PDF
Hybrid model detection and classification of lung cancer
PDF
A comparative analysis of optical character recognition models for extracting...
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
August Patch Tuesday
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
Getting Started with Data Integration: FME Form 101
PDF
Web App vs Mobile App What Should You Build First.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
Assigned Numbers - 2025 - Bluetooth® Document
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Tartificialntelligence_presentation.pptx
Univ-Connecticut-ChatGPT-Presentaion.pdf
project resource management chapter-09.pdf
Chapter 5: Probability Theory and Statistics
A comparative study of natural language inference in Swahili using monolingua...
WOOl fibre morphology and structure.pdf for textiles
Mushroom cultivation and it's methods.pdf
Hybrid model detection and classification of lung cancer
A comparative analysis of optical character recognition models for extracting...
SOPHOS-XG Firewall Administrator PPT.pptx
August Patch Tuesday
cloud_computing_Infrastucture_as_cloud_p
Getting Started with Data Integration: FME Form 101
Web App vs Mobile App What Should You Build First.pdf
Encapsulation_ Review paper, used for researhc scholars

DCI with Ruby and Rails