![Page 1: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/1.jpg)
SAY GOODBYE TO
PROCEDURAL*PROGRAMMING
ANOTHER USELESS PRESENTATION BROUGHT TO YOU BY @APOTONICK
![Page 2: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/2.jpg)
SAY GOODBYE TO
PROCEDURAL*PROGRAMMING
* AS WE KNOW IT.
![Page 3: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/3.jpg)
![Page 4: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/4.jpg)
<wrong>
![Page 5: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/5.jpg)
REVEAL.JSAND HOW TO MASTER IT, PART I OF VIII
![Page 6: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/6.jpg)
[ ] 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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/7.jpg)
[ ] 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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/8.jpg)
![Page 9: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/9.jpg)
![Page 10: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/10.jpg)
![Page 11: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/11.jpg)
![Page 12: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/12.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/13.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/14.jpg)
![Page 15: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/15.jpg)
![Page 16: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/16.jpg)
![Page 17: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/17.jpg)
![Page 18: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/18.jpg)
![Page 19: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/19.jpg)
![Page 20: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/20.jpg)
![Page 21: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/21.jpg)
![Page 22: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/22.jpg)
![Page 23: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/23.jpg)
![Page 24: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/24.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/25.jpg)
![Page 26: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/26.jpg)
I SAID: RAILS VIEWS!
![Page 27: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/27.jpg)
![Page 28: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/28.jpg)
![Page 29: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/29.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/30.jpg)
HOW DO I TEST THAT?
![Page 31: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/31.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/32.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/33.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/34.jpg)
![Page 35: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/35.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/36.jpg)
![Page 37: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/37.jpg)
...THINKING...
![Page 38: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/38.jpg)
...THINKING...
![Page 39: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/39.jpg)
![Page 40: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/40.jpg)
![Page 41: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/41.jpg)
![Page 42: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/42.jpg)
[...] It extends the basic MVC patternwith new abstractions.
![Page 43: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/43.jpg)
NO!
![Page 44: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/44.jpg)
![Page 45: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/45.jpg)
![Page 46: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/46.jpg)
![Page 47: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/47.jpg)
![Page 48: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/48.jpg)
class MyService def self.call(args)
# do something here
end
end
MyService.( valid_params )
![Page 49: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/49.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/50.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/51.jpg)
![Page 52: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/52.jpg)
[ ] 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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/53.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/54.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/55.jpg)
HAPPY!
![Page 56: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/56.jpg)
...THINKING...
![Page 57: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/57.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/58.jpg)
Is the problem the procedural* code design?
![Page 59: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/59.jpg)
![Page 60: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/60.jpg)
![Page 61: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/61.jpg)
![Page 62: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/62.jpg)
![Page 63: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/63.jpg)
AND THAT'S TRB.
THANK YOU!
![Page 64: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/64.jpg)
QUESTIONS?
![Page 65: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/65.jpg)
OK, I GOT
A QUESTIONTHEN:
![Page 66: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/66.jpg)
DO YOU WANTSOME CODE?
![Page 67: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/67.jpg)
DO YOU WANTSOME CODE?
![Page 68: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/68.jpg)
NO?
![Page 69: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/69.jpg)
class Create < Trailblazer::Operation #
#
#
end
![Page 70: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/70.jpg)
class BlogPost::Create < Trailblazer::Operation #
#
#
end
![Page 71: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/71.jpg)
class Create < Trailblazer::Operation #
#
#
end
![Page 72: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/72.jpg)
class Create < Trailblazer::Operation def process(params)
# sam's code here
end
end
![Page 73: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/73.jpg)
Notes: not really extendable
![Page 74: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/74.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/75.jpg)
class Create < Trailblazer::Operation #
#
#
end
result = Create.()
result.success? #=> true
![Page 76: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/76.jpg)
Notes:
Hooray, we have an API for service objects!
![Page 77: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/77.jpg)
HOORAY, A
SERVICEOBJECT
API!
![Page 78: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/78.jpg)
class Create < Trailblazer::Operation #
#
#
#
end
![Page 79: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/79.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/80.jpg)
![Page 81: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/81.jpg)
![Page 82: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/82.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/83.jpg)
class Create < Trailblazer::Operation step :create_model!
#
#
#
#
end
![Page 84: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/84.jpg)
class Create < Trailblazer::Operation step :create_model!
def create_model!(options, **)
end
end
![Page 85: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/85.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/86.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/87.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/88.jpg)
Notes: sending params into the op
![Page 89: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/89.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/90.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/91.jpg)
![Page 92: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/92.jpg)
![Page 93: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/93.jpg)
![Page 94: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/94.jpg)
#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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/95.jpg)
#class Create < Trailblazer::Operation
# ..
def validate!(options, params:, model:, **)
#
#
#
#
model.update_attributes(params)
end
#end
![Page 96: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/96.jpg)
![Page 97: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/97.jpg)
![Page 98: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/98.jpg)
class Create < Trailblazer::Operation step :create_model!
step :validate!
step :save!
#
#
#
#
#
#
end
![Page 99: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/99.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/100.jpg)
![Page 101: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/101.jpg)
![Page 102: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/102.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/103.jpg)
HAPPYTIMES!
![Page 104: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/104.jpg)
... AND WHEN
THINGSGO WRONG?
![Page 105: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/105.jpg)
![Page 106: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/106.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/107.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/108.jpg)
![Page 109: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/109.jpg)
![Page 110: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/110.jpg)
#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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/111.jpg)
![Page 112: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/112.jpg)
![Page 113: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/113.jpg)
![Page 114: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/114.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/115.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/116.jpg)
result = Create.( { title: nil } )
result.success? #=> false
result["error"] = "don't cry!"
![Page 117: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/117.jpg)
RAILWAYSROCK!
![Page 118: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/118.jpg)
BUT ISN'T THAT
SUPERCOMPLEX?
![Page 119: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/119.jpg)
DUDE.
![Page 120: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/120.jpg)
![Page 121: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/121.jpg)
Notes: do you find this more complex than this?
![Page 122: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/122.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/123.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/124.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/125.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/126.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/127.jpg)
rspec-trailblazer
minitest-trailblazer
![Page 128: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/128.jpg)
![Page 129: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/129.jpg)
![Page 130: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/130.jpg)
Notes:
validations still in model
![Page 131: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/131.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/132.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/133.jpg)
AUTHORIZATIONdef create
return unless can?(current_user, Post, :new)
# ..
![Page 134: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/134.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/135.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/136.jpg)
CURRENT WHAT?
![Page 137: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/137.jpg)
def authorize!(options, current_user:, **)
CouldCould.can?(
current_user, # wtf?
Post, :new
)
end
![Page 138: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/138.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/139.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/140.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/141.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/142.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/143.jpg)
class PostsController < ApplicationController def create
run BlogPost::Create do
return
end
render :new
end
end
![Page 144: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/144.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/145.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/146.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/147.jpg)
![Page 148: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/148.jpg)
![Page 149: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/149.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/150.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/151.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/152.jpg)
DYI SUCKS
![Page 153: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/153.jpg)
class Create < Trailblazer::Operation step Policy::CanCan( Post, :new )
# step :model!
# ..
end
![Page 154: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/154.jpg)
![Page 155: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/155.jpg)
![Page 156: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/156.jpg)
VALIDATIONS:A STORY OF MANKIND
![Page 157: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/157.jpg)
![Page 158: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/158.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/159.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/160.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/161.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/162.jpg)
![Page 163: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/163.jpg)
![Page 164: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/164.jpg)
![Page 165: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/165.jpg)
![Page 166: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/166.jpg)
BPMN
![Page 167: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/167.jpg)
![Page 168: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/168.jpg)
![Page 169: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/169.jpg)
![Page 170: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/170.jpg)
![Page 171: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/171.jpg)
![Page 172: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/172.jpg)
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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/173.jpg)
![Page 174: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/174.jpg)
result = Create.(
params,
"current_user" => ..
)
![Page 175: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/175.jpg)
SAY GOODBYE TO
PROCEDURAL*PROGRAMMING
* AS WE KNOW IT.
![Page 176: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/176.jpg)
Trailblazer is awesome! -- Someone
![Page 177: Say Goodbye to Procedural Programming - Nick Sutterer](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/177.jpg)
[ ] 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](https://reader031.vdocument.in/reader031/viewer/2022030308/58ecfb481a28ab745f8b4751/html5/thumbnails/178.jpg)
@APOTONICK ❤