Your browser doesn't support the features required by impress.js, so you are presented with a simplified version of this presentation.

For the best experience please use the latest Chrome, Safari or Firefox browser.

DCI - The End User Architecture

Mike Pack

@zombidev

Overview

Monolithic Rails Model

Monolithic Rails Model

“The problem with object-oriented languages is they’ve got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle.” - Joe Armstrong

Skinny Controllers

Overview

Fat Controllers

Decoupling Fat Controllers

Overview

Data, Context and Interaction

DCI - Motivation/Foundation


Why?

DCI - Overview

Overview

User Stories

"As a publisher, I want to publish a blog post."
User stories should:

Data, Context and Interaction

Interaction = Roles

Data, Context and Interaction

Interaction = Roles

"What the system does"

          module Publisher
            def publish(post)
              post.publish
            end
          end
        
Roles should:

Data, Context and Interaction

Connects data objects with roles

Data, Context and Interaction

Connects data objects with roles

          class UserPublishesPostContext
            def initialize(user, post)
              @publisher, @post = user, post
              @publisher.extend Publisher            # extend instance!
            end
            def call
              @publisher.publish(@post)
            end
          end

          # Within the controller...
          @user = current_user
          @post = Post.find(params[:id])
          UserPublishesPostContext.new(@user, @post).call
        

Data, Context and Interaction

Connects data objects with roles

Contexts should:

Data, Context and Interaction

Data = Rails Models

Data, Context and Interaction

Data = Rails Model

"What the system is."

          class Post < ActiveRecord::Base
            validates :title, :presence => true
            
            def publish
              update_attribute(:published_at, Time.zone.now)
            end
          end
        
Data should:

Overview

What the system is
vs
What the system does

DCI Will Help You...

This is an intro...there's more...

Let's talk about it.

Thanks

@zombidev