178
SAY GOODBYE TO PROCEDURAL* PROGRAMMING ANOTHER USELESS PRESENTATION BROUGHT TO YOU BY @APOTONICK

Say Goodbye to Procedural Programming - Nick Sutterer

Embed Size (px)

Citation preview

Page 1: Say Goodbye to Procedural Programming - Nick Sutterer

SAY GOODBYE TO

PROCEDURAL*PROGRAMMING

ANOTHER USELESS PRESENTATION BROUGHT TO YOU BY @APOTONICK

Page 2: Say Goodbye to Procedural Programming - Nick Sutterer

SAY GOODBYE TO

PROCEDURAL*PROGRAMMING

* AS WE KNOW IT.

Page 3: Say Goodbye to Procedural Programming - Nick Sutterer
Page 4: Say Goodbye to Procedural Programming - Nick Sutterer

<wrong>

Page 5: Say Goodbye to Procedural Programming - Nick Sutterer

REVEAL.JSAND HOW TO MASTER IT, PART I OF VIII

Page 6: Say Goodbye to Procedural Programming - Nick Sutterer

[ ] DIAGRAMS[ ] 6 MEMES[ ] 2 BULLET POINT LISTS[ ] QUOTE FROM SOMEONE[ ] MORE DIAGRAMS[ ] TRUCKLOADS OF CODE (you wanted it)

Page 7: Say Goodbye to Procedural Programming - Nick Sutterer

[ ] DIAGRAMS[ ] 6 MEMES[x ] 2 BULLET POINT LISTS[ ] QUOTE FROM SOMEONE[ ] MORE DIAGRAMS[ ] TRUCKLOADS OF CODE (you wanted it)

Page 8: Say Goodbye to Procedural Programming - Nick Sutterer
Page 9: Say Goodbye to Procedural Programming - Nick Sutterer
Page 10: Say Goodbye to Procedural Programming - Nick Sutterer
Page 11: Say Goodbye to Procedural Programming - Nick Sutterer
Page 12: Say Goodbye to Procedural Programming - Nick Sutterer

class Post < ActiveRecord::Base validates :body, presence:true

validates :author, presence:true

after_save :notify_moderators!, if: :create?

end

Page 13: Say Goodbye to Procedural Programming - Nick Sutterer

 class PostsController < ApplicationController def create

return unless can?(current_user, Post, :new)

post = Post.new(author: current_user)

if post.update_attributes(

params.require(:post).permit(:title)

)

post.save

notify_current_user!

else

render :new

end

end

end

Page 14: Say Goodbye to Procedural Programming - Nick Sutterer
Page 15: Say Goodbye to Procedural Programming - Nick Sutterer
Page 16: Say Goodbye to Procedural Programming - Nick Sutterer
Page 17: Say Goodbye to Procedural Programming - Nick Sutterer
Page 18: Say Goodbye to Procedural Programming - Nick Sutterer
Page 19: Say Goodbye to Procedural Programming - Nick Sutterer
Page 20: Say Goodbye to Procedural Programming - Nick Sutterer
Page 21: Say Goodbye to Procedural Programming - Nick Sutterer
Page 22: Say Goodbye to Procedural Programming - Nick Sutterer
Page 23: Say Goodbye to Procedural Programming - Nick Sutterer
Page 24: Say Goodbye to Procedural Programming - Nick Sutterer

Let's not talk about persistence!

Let's not talk about business logic!

Let's not talk about views!

Page 25: Say Goodbye to Procedural Programming - Nick Sutterer
Page 26: Say Goodbye to Procedural Programming - Nick Sutterer

I SAID: RAILS VIEWS!

Page 27: Say Goodbye to Procedural Programming - Nick Sutterer
Page 28: Say Goodbye to Procedural Programming - Nick Sutterer
Page 29: Say Goodbye to Procedural Programming - Nick Sutterer

Notes:

let's come back to the problems in our example it'shard to understand what we are trying to do and:

Page 30: Say Goodbye to Procedural Programming - Nick Sutterer

HOW DO I TEST THAT?

Page 31: Say Goodbye to Procedural Programming - Nick Sutterer

class Post < ActiveRecord::Base validates :body, presence:true

validates :author, presence:true

after_save :notify_moderators!, if: :create?

end

describe Post do

it "validates and notifies moderators" do

post = Post.create( valid_params )

expect(post).to be_persisted

end

end

Page 32: Say Goodbye to Procedural Programming - Nick Sutterer

class Post < ActiveRecord::Base

validates :body, presence:true

validates :author, presence:true

after_save :notify_moderators!, if: :create?

end

describe Post do

it "validates and notifies moderators" do

post = Post.create( valid_params )

expect(post).to be_persisted

end

end

Page 33: Say Goodbye to Procedural Programming - Nick Sutterer

it do

controller = Controller.new

controller.create( valid_params )

expect(Post.last).to be_persisted

end

Page 34: Say Goodbye to Procedural Programming - Nick Sutterer
Page 35: Say Goodbye to Procedural Programming - Nick Sutterer

describe BlogPostsController do

it "creates BlogPost model" do

post :create, blog_post: valid_params

expect(response).to be_ok

expect(BlogPost.last).to be_persisted

end

end

Page 36: Say Goodbye to Procedural Programming - Nick Sutterer
Page 37: Say Goodbye to Procedural Programming - Nick Sutterer

...THINKING...

Page 38: Say Goodbye to Procedural Programming - Nick Sutterer

...THINKING...

Page 39: Say Goodbye to Procedural Programming - Nick Sutterer
Page 40: Say Goodbye to Procedural Programming - Nick Sutterer
Page 41: Say Goodbye to Procedural Programming - Nick Sutterer
Page 42: Say Goodbye to Procedural Programming - Nick Sutterer

[...] It extends the basic MVC patternwith new abstractions.

Page 43: Say Goodbye to Procedural Programming - Nick Sutterer

NO!

Page 44: Say Goodbye to Procedural Programming - Nick Sutterer
Page 45: Say Goodbye to Procedural Programming - Nick Sutterer
Page 46: Say Goodbye to Procedural Programming - Nick Sutterer
Page 47: Say Goodbye to Procedural Programming - Nick Sutterer
Page 48: Say Goodbye to Procedural Programming - Nick Sutterer

class MyService def self.call(args)

# do something here

end

end

MyService.( valid_params )

Page 49: Say Goodbye to Procedural Programming - Nick Sutterer

Notes: we don't need any domain logic, that's veryuser specific and shouldn't be dictated by "my

framework"

Page 50: Say Goodbye to Procedural Programming - Nick Sutterer

class MyService def call(params)

return unless can?(current_user, Post, :new)

post = Post.new(author: current_user)

post.update_attributes(

params.require(:post).permit(:title)

)

if post.save

notify_current_user!

end

end

end

Page 51: Say Goodbye to Procedural Programming - Nick Sutterer
Page 52: Say Goodbye to Procedural Programming - Nick Sutterer

[ ] DIAGRAMS[x] 6 MEMES[x ] 2 BULLET POINT LISTS[ ] QUOTE FROM SOMEONE[ ] MORE DIAGRAMS[ ] TRUCKLOADS OF CODE (you wanted it)

Page 53: Say Goodbye to Procedural Programming - Nick Sutterer

class MyService def call(params)

return unless can?(current_user, Post, :new)

post = Post.new(author: current_user)

post.update_attributes(

params.require(:post).permit(:title)

)

if post.save

notify_current_user!

end

end

end

Page 54: Say Goodbye to Procedural Programming - Nick Sutterer

TESTit do

service = MyService.new

service.call( valid_params )

expect(Post.last).to be_persisted

end

Page 55: Say Goodbye to Procedural Programming - Nick Sutterer

HAPPY!

Page 56: Say Goodbye to Procedural Programming - Nick Sutterer

...THINKING...

Page 57: Say Goodbye to Procedural Programming - Nick Sutterer

SERVICE OBJECTS, REVISITED

[x] Encapsulation[x] Testing[ ] What to return?[ ] Validations extracted?[ ] Extendable

class MyService def call(params)

end

end

Page 58: Say Goodbye to Procedural Programming - Nick Sutterer

Is the problem the procedural* code design?

Page 59: Say Goodbye to Procedural Programming - Nick Sutterer
Page 60: Say Goodbye to Procedural Programming - Nick Sutterer
Page 61: Say Goodbye to Procedural Programming - Nick Sutterer
Page 62: Say Goodbye to Procedural Programming - Nick Sutterer
Page 63: Say Goodbye to Procedural Programming - Nick Sutterer

AND THAT'S TRB.

THANK YOU!

Page 64: Say Goodbye to Procedural Programming - Nick Sutterer

QUESTIONS?

Page 65: Say Goodbye to Procedural Programming - Nick Sutterer

OK, I GOT

A QUESTIONTHEN:

Page 66: Say Goodbye to Procedural Programming - Nick Sutterer

DO YOU WANTSOME CODE?

Page 67: Say Goodbye to Procedural Programming - Nick Sutterer

DO YOU WANTSOME CODE?

Page 68: Say Goodbye to Procedural Programming - Nick Sutterer

NO?

Page 69: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation #

#

#

end

Page 70: Say Goodbye to Procedural Programming - Nick Sutterer

class BlogPost::Create < Trailblazer::Operation #

#

#

end

Page 71: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation #

#

#

end

Page 72: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation def process(params)

# sam's code here

end

end

Page 73: Say Goodbye to Procedural Programming - Nick Sutterer

Notes: not really extendable

Page 74: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation def process(params)

return unless can?(current_user, Post, :new)

post = Post.new(author: current_user)

post.update_attributes(

params.require(:post).permit(:title)

)

if post.save

notify_current_user!

end

end

end

Page 75: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation #

#

#

end

result = Create.()

result.success? #=> true

Page 76: Say Goodbye to Procedural Programming - Nick Sutterer

Notes:

Hooray, we have an API for service objects!

Page 77: Say Goodbye to Procedural Programming - Nick Sutterer

HOORAY, A

SERVICEOBJECT

API!

Page 78: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation #

#

#

#

end

Page 79: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation step :create_model!

step :validate!

step :save!

step :notify_current_user!

end

Page 80: Say Goodbye to Procedural Programming - Nick Sutterer
Page 81: Say Goodbye to Procedural Programming - Nick Sutterer
Page 82: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation step :create_model!

step :validate!

step :save!

step :notify_current_user!

end

Page 83: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation step :create_model!

#

#

#

#

end

Page 84: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation step :create_model!

def create_model!(options, **)

end

end

Page 85: Say Goodbye to Procedural Programming - Nick Sutterer

CREATE MODELclass Create < Trailblazer::Operation step :create_model!

def create_model!(options, **)

options["model"] = BlogPost.new

end

end

result = Create.()

result.success? #=> true

result["model"] #=> #<BlogPost id:nil, ..>

Page 86: Say Goodbye to Procedural Programming - Nick Sutterer

VALIDATEclass Create < Trailblazer::Operation step :create_model!

step :validate!

def create_model!(options, **)

# ..

def validate!(options, params:, **)

# validate params

end

end

Page 87: Say Goodbye to Procedural Programming - Nick Sutterer

valid_params = { body: "Blogging's fun. #not" }

Create.( valid_params )

class Create < Trailblazer::Operation # ..

def validate!(options, params:, **)

params #=> { body: "Blogging's fun. #not" }

end

end

Page 88: Say Goodbye to Procedural Programming - Nick Sutterer

Notes: sending params into the op

Page 89: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation # ..

def validate!(options, params:, **)

model = options["model"] # from the create_model! step...

if model.update_attributes(params)

true

else

false

end

end

end

Page 90: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation # ..

def validate!(options, params:, model:, **)

#

#

if model.update_attributes(params)

true

else

false

end

end

end

Page 91: Say Goodbye to Procedural Programming - Nick Sutterer
Page 92: Say Goodbye to Procedural Programming - Nick Sutterer
Page 93: Say Goodbye to Procedural Programming - Nick Sutterer
Page 94: Say Goodbye to Procedural Programming - Nick Sutterer

#class Create < Trailblazer::Operation

# ..

def validate!(options, params:, model:, **)

if model.update_attributes(params)

true

else

false

end

end

#end

Page 95: Say Goodbye to Procedural Programming - Nick Sutterer

#class Create < Trailblazer::Operation

# ..

def validate!(options, params:, model:, **)

#

#

#

#

model.update_attributes(params)

end

#end

Page 96: Say Goodbye to Procedural Programming - Nick Sutterer
Page 97: Say Goodbye to Procedural Programming - Nick Sutterer
Page 98: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation step :create_model!

step :validate!

step :save!

#

#

#

#

#

#

end

Page 99: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation step :create_model!

step :validate!

step :save!

#def create_model!(options, **)

#def validate!(options, params:, **)

def save!(options, params:, model:, **)

true

end

end

Page 100: Say Goodbye to Procedural Programming - Nick Sutterer
Page 101: Say Goodbye to Procedural Programming - Nick Sutterer
Page 102: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation step :create_model!

step :validate!

step :save!

step :notify!

#def create_model!(options, **)

#def validate!(options, params:, **)

#def save!(options, params:, model:, **)

def notify!(options, model:, **)

MyMailer.call(model)

end

end

Page 103: Say Goodbye to Procedural Programming - Nick Sutterer

HAPPYTIMES!

Page 104: Say Goodbye to Procedural Programming - Nick Sutterer

... AND WHEN

THINGSGO WRONG?

Page 105: Say Goodbye to Procedural Programming - Nick Sutterer
Page 106: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation step :create_model!

step :validate!

step :save!

step :notify!

#def create_model!(options, **)

#def validate!(options, params:, **)

#def save!(options, params:, model:, **)

#def notify!(options, model:, **)

end

Page 107: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation step :create_model!

step :validate! [XXX]

step :save!

step :notify!

#def create_model!(options, **)

#def validate!(options, params:, **)

#def save!(options, params:, model:, **)

#def notify!(options, model:, **)

end

Page 108: Say Goodbye to Procedural Programming - Nick Sutterer
Page 109: Say Goodbye to Procedural Programming - Nick Sutterer
Page 110: Say Goodbye to Procedural Programming - Nick Sutterer

#class Create < Trailblazer::Operation

# ..

def validate!(options, params:, model:, **)

model.update_attributes(params) #=> false

end

#end

Page 111: Say Goodbye to Procedural Programming - Nick Sutterer
Page 112: Say Goodbye to Procedural Programming - Nick Sutterer
Page 113: Say Goodbye to Procedural Programming - Nick Sutterer
Page 114: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation step :create_model!

step :validate!

step :save!

step :notify!

failure :handle!

#..

end

Page 115: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation step :create_model!

step :validate!

step :save!

step :notify!

failure :handle!

#..

def handle!(options, **)

options["error"] = "don't cry!"

end

end

Page 116: Say Goodbye to Procedural Programming - Nick Sutterer

result = Create.( { title: nil } )

result.success? #=> false

result["error"] = "don't cry!"

Page 117: Say Goodbye to Procedural Programming - Nick Sutterer

RAILWAYSROCK!

Page 118: Say Goodbye to Procedural Programming - Nick Sutterer

BUT ISN'T THAT

SUPERCOMPLEX?

Page 119: Say Goodbye to Procedural Programming - Nick Sutterer

DUDE.

Page 120: Say Goodbye to Procedural Programming - Nick Sutterer
Page 121: Say Goodbye to Procedural Programming - Nick Sutterer

Notes: do you find this more complex than this?

Page 122: Say Goodbye to Procedural Programming - Nick Sutterer

class MyService def call(params)

return unless can?(current_user, Post, :new)

post = Post.new(author: current_user)

if post.update_attributes(

params.require(:post).permit(:title)

)

unless notify_current_user!

if ...

else

end

end

end

Page 123: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation step :create_model!

step :validate!

step :save!

step :notify!

failure :handle!

# ..

end

Page 124: Say Goodbye to Procedural Programming - Nick Sutterer

def create_model!(options, **)

def validate!( options, params:, **)

def save!( options, params:, model:, **)

def notify!( options, model:, **)

Page 125: Say Goodbye to Procedural Programming - Nick Sutterer

result = Create.( { title: nil } )

result.success? #=> false

result["error"] #=> "don't cry!"

result["model"] #=> #<BlogPost title: nil>

Page 126: Say Goodbye to Procedural Programming - Nick Sutterer

TESTit "fails with empty title" do

result = Create.( { title: nil } )

expect(result).to be_success

expect(result["error"]).to eq("don't cry!")

expect(result["model"]).to be_persisted

end

Page 127: Say Goodbye to Procedural Programming - Nick Sutterer

rspec-trailblazer

minitest-trailblazer

Page 128: Say Goodbye to Procedural Programming - Nick Sutterer
Page 129: Say Goodbye to Procedural Programming - Nick Sutterer
Page 130: Say Goodbye to Procedural Programming - Nick Sutterer

Notes:

validations still in model

Page 131: Say Goodbye to Procedural Programming - Nick Sutterer

class PostsController < ApplicationController def create

return unless can?(current_user, Post, :new)

post = Post.new(author: current_user)

if post.update_attributes(

params.require(:post).permit(:title))

notify_current_user!

else

render :new

end

end

end

Page 132: Say Goodbye to Procedural Programming - Nick Sutterer

class PostsController < ApplicationController def create

return unless can?(current_user, Post, :new)

#

#

#

result = BlogPost::Create.( params )

if result.failure?

render :new

end

end

end

Page 133: Say Goodbye to Procedural Programming - Nick Sutterer

AUTHORIZATIONdef create

return unless can?(current_user, Post, :new)

# ..

Page 134: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation step :authorize!

#step :create_model!

#step :validate!

#step :save!

#step :notify!

#failure :handle!

# ..

end

Page 135: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation step :authorize!

# ..

def authorize!(options, current_user:, **)

CouldCould.can?(current_user, Post, :new)

end

end

Page 136: Say Goodbye to Procedural Programming - Nick Sutterer

CURRENT WHAT?

Page 137: Say Goodbye to Procedural Programming - Nick Sutterer

def authorize!(options, current_user:, **)

CouldCould.can?(

current_user, # wtf?

Post, :new

)

end

Page 138: Say Goodbye to Procedural Programming - Nick Sutterer

class PostsController < ApplicationController def create

return unless can?(current_user, Post, :new)

result = BlogPost::Create.( params )

#

#

#

if result.failure?

render :new

end

end

end

Page 139: Say Goodbye to Procedural Programming - Nick Sutterer

class PostsController < ApplicationController def create

return unless can?(current_user, Post, :new)

result = BlogPost::Create.(

params,

"current_user" => current_user

)

if result.failure?

render :new

end

end

end

Page 140: Say Goodbye to Procedural Programming - Nick Sutterer

class PostsController < ApplicationController def create

#return unless can?(current_user, Post, :new)

#

result = BlogPost::Create.(

params,

"current_user" => current_user

)

if result.failure?

render :new

end

end

end

Page 141: Say Goodbye to Procedural Programming - Nick Sutterer

class PostsController < ApplicationController def create

result = BlogPost::Create.(

params,

"current_user" => current_user

)

if result.failure?

render :new

end

end

end

Page 142: Say Goodbye to Procedural Programming - Nick Sutterer

class PostsController < ApplicationController def create

run BlogPost::Create, "current_user" => current_user do

return

end

render :new

end

end

Page 143: Say Goodbye to Procedural Programming - Nick Sutterer

class PostsController < ApplicationController def create

run BlogPost::Create do

return

end

render :new

end

end

Page 144: Say Goodbye to Procedural Programming - Nick Sutterer

class PostsController < ApplicationController def create

run BlogPost::Create do |result|

return redirect_to blog_post_path(result["model"].id)

end

render :new

end

end

Page 145: Say Goodbye to Procedural Programming - Nick Sutterer

class PostsController < ApplicationController def create

run BlogPost::Create do |result|

return redirect_to blog_post_path(result["model"

end

render :new

end

end

Page 146: Say Goodbye to Procedural Programming - Nick Sutterer

DEPENDENCY INJECTION it "works with current_user" do

result = Create.(

valid_params,

"current_user" => User.find(1) )

# ..

end

Page 147: Say Goodbye to Procedural Programming - Nick Sutterer
Page 148: Say Goodbye to Procedural Programming - Nick Sutterer
Page 149: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation step :authorize!

# ..

def authorize!(options, current_user:, **)

CouldCould.can?(current_user, Post, :new)

end

end

Page 150: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation step MyAuth

# ..

class MyAuth def self.call(options, current_user:, **)

CouldCould.can?(current_user, Post, :new)

end

end

end

Page 151: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation step MyAuthCallableSittingSomewhere

# ..

#class MyAuth

# def self.call(options, current_user:, **)

# CouldCould.can?(current_user, Post, :new)

# end

#end

end

Page 152: Say Goodbye to Procedural Programming - Nick Sutterer

DYI SUCKS

Page 153: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation step Policy::CanCan( Post, :new )

# step :model!

# ..

end

Page 154: Say Goodbye to Procedural Programming - Nick Sutterer
Page 155: Say Goodbye to Procedural Programming - Nick Sutterer
Page 156: Say Goodbye to Procedural Programming - Nick Sutterer

VALIDATIONS:A STORY OF MANKIND

Page 157: Say Goodbye to Procedural Programming - Nick Sutterer
Page 158: Say Goodbye to Procedural Programming - Nick Sutterer

class Post < ActiveRecord::Base validates :title, presence:true

validates :body, presence:true

#after_save :notify_moderators!, if: :create?

end

Page 159: Say Goodbye to Procedural Programming - Nick Sutterer

module BlogPost module Contract class Create::Create < Reform::Form property :title

property :body

validates :title, presence:true

validates :body, presence:true

end

end

end

Page 160: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation step Policy::CanCan( Post, :new )

step :model!

step :validate!

step :notify!

# ..

def model!(options, **)

def validate!(options, **)

# ..

end

Page 161: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation step Policy::CanCan( Post, :new )

step :model!

step Contract::Build( constant: Contract::Create )

step Contract::Validate()

step Contract::Persist()

step :notify!

# ..

def model!(options, **)

# ..

end

Page 162: Say Goodbye to Procedural Programming - Nick Sutterer
Page 163: Say Goodbye to Procedural Programming - Nick Sutterer
Page 164: Say Goodbye to Procedural Programming - Nick Sutterer
Page 165: Say Goodbye to Procedural Programming - Nick Sutterer
Page 166: Say Goodbye to Procedural Programming - Nick Sutterer

BPMN

Page 167: Say Goodbye to Procedural Programming - Nick Sutterer
Page 168: Say Goodbye to Procedural Programming - Nick Sutterer
Page 169: Say Goodbye to Procedural Programming - Nick Sutterer
Page 170: Say Goodbye to Procedural Programming - Nick Sutterer
Page 171: Say Goodbye to Procedural Programming - Nick Sutterer
Page 172: Say Goodbye to Procedural Programming - Nick Sutterer

class Create < Trailblazer::Operation step :create_model!

step :validate!

step :save!

step :notify!

failure :handle!

# ..

end

Page 173: Say Goodbye to Procedural Programming - Nick Sutterer
Page 174: Say Goodbye to Procedural Programming - Nick Sutterer

result = Create.(

params,

"current_user" => ..

)

Page 175: Say Goodbye to Procedural Programming - Nick Sutterer

SAY GOODBYE TO

PROCEDURAL*PROGRAMMING

* AS WE KNOW IT.

Page 176: Say Goodbye to Procedural Programming - Nick Sutterer

Trailblazer is awesome!              -- Someone

Page 177: Say Goodbye to Procedural Programming - Nick Sutterer

[ ] DIAGRAMS[x] 6 MEMES[xX] 2 BULLET POINT LISTS[x] QUOTE FROM SOMEONE[x] MORE DIAGRAMS[ ] TRUCKLOADS OF CODE (you wanted it)

Page 178: Say Goodbye to Procedural Programming - Nick Sutterer

@APOTONICK ❤