SlideShare une entreprise Scribd logo
1  sur  52
Télécharger pour lire hors ligne
THE END
OF RAILS?
@APOTONICK
THE ILLUSION
OF STABLE APIS
@APOTONICK
End of-rails-wids
End of-rails-wids
End of-rails-wids
End of-rails-wids
End of-rails-wids
End of-rails-wids
End of-rails-wids
End of-rails-wids
End of-rails-wids
End of-rails-wids
End of-rails-wids
End of-rails-wids
“Most Rails developers do not write
object-oriented Ruby code.
They write MVC-oriented Ruby code by
putting models and controllers in the
expected locations.
It takes 2-3 years before developers
realize: “Rails is just Ruby.”
-- Mike Perham
End of-rails-wids
End of-rails-wids
End of-rails-wids
RAILS’
OBSESSION
WITH “MVC”
End of-rails-wids
class User < ActiveRecord::Base
validates :name, length: 20
validates :email, format: email
validates :age, numericality: true
class User < ActiveRecord::Base
validates :name, length: 20
validates :email, format: email
validates :age, numericality: true
User.create(
name: “RISE!”,
email: “rise@”
age: 21
)
class User < ActiveRecord::Base
validates :name, length: 20
validates :email, format: email
validates :age, numericality: true
class User < ActiveRecord::Base
validates :name, length: 20
validates :email, format: email
validates :age, numericality: true
class User < ActiveRecord::Base
validates :name, length: 20
validates :email, format: email
validates :age, numericality: true
User.create(
name: “RISE! This user is by ADMIN!”,
email: “rise@”
age: 21
)
class User < ActiveRecord::Base
validates :name, length: 20
validates :email, format: email
validates :age, numericality: true
User.create(
name: “RISE! This user is by ADMIN!”,
email: “rise@”
age: 21
)
class User < ActiveRecord::Base
validates :name, length: 20,
unless: → { creator_is_admin? }
validates :email, format: email
validates :age, numericality: true
User.create(
name: “RISE! This user is by ADMIN!”,
email: “rise@”
age: 21
)
End of-rails-wids
End of-rails-wids
class User
End of-rails-wids
defmodule User do
use Ecto.Schema
import Ecto.Changeset
schema "users" do
field :name
field :email
field :age, :integer
end
def changeset(user, params  :empty) do
user
|> cast(params, ~w(name email), ~w(age))
|> validate_format(:email, ~r/@/)
|> validate_inclusion(:age, 18..100)
|> unique_constraint(:email)
end
end
End of-rails-wids
defmodule User do
use Ecto.Schema
import Ecto.Changeset
schema "users" do
field :name
field :email
field :age, :integer
end
def changeset(user, params  :empty) do
user
|> cast(params, ~w(name email), ~w(age))
|> validate_format(:email, ~r/@/)
|> validate_inclusion(:age, 18..100)
|> unique_constraint(:email)
end
end
defmodule User do
use Ecto.Schema
import Ecto.Changeset
schema "users" do
field :name
field :email
field :age, :integer
end
def changeset(user, params  :empty) do
user
|> cast(params, ~w(name email), ~w(age))
|> validate_format(:email, ~r/@/)
|> validate_inclusion(:age, 18..100)
|> unique_constraint(:email)
end
end
class User
User
User.Admin
End of-rails-wids
class User::Create < Trailblazer::Operation
model User
contract do
property :name
property :email
property :age, type: Integer
validates :email, format: email
validates :age, inclusion: 1..200
end
def process(params)
validate(params) do
contract.save
end
end
end
End of-rails-wids
class User::Create < Trailblazer::Operation
model User
contract do
property :name
property :email
property :age, type: Integer
validates :email, format: email
validates :age, inclusion: 1..200
end
def process(params)
validate(params) do
contract.save
end
end
end
class User::Create < Trailblazer::Operation
model User
contract do
property :name
property :email
property :age, type: Integer
validates :email, format: email
validates :age, inclusion: 1..200
end
def process(params)
validate(params) do
contract.save
end
end
end
class User
User::Create
User::Create::Admin
End of-rails-wids
APIs
MUST
CHANGE!
End of-rails-wids
End of-rails-wids
End of-rails-wids
APIs
MUST
CHANGE!
APIs
MUST
CHANGE!INNOVATION ==
@APOTONICK

Contenu connexe

En vedette

Who's More Functional: Kotlin, Groovy, Scala, or Java?
Who's More Functional: Kotlin, Groovy, Scala, or Java?Who's More Functional: Kotlin, Groovy, Scala, or Java?
Who's More Functional: Kotlin, Groovy, Scala, or Java?
Andrey Breslav
 

En vedette (13)

Black Ops of TCP/IP 2011 (Black Hat USA 2011)
Black Ops of TCP/IP 2011 (Black Hat USA 2011)Black Ops of TCP/IP 2011 (Black Hat USA 2011)
Black Ops of TCP/IP 2011 (Black Hat USA 2011)
 
Introduction to Functional Programming in JavaScript
Introduction to Functional Programming in JavaScriptIntroduction to Functional Programming in JavaScript
Introduction to Functional Programming in JavaScript
 
Who's More Functional: Kotlin, Groovy, Scala, or Java?
Who's More Functional: Kotlin, Groovy, Scala, or Java?Who's More Functional: Kotlin, Groovy, Scala, or Java?
Who's More Functional: Kotlin, Groovy, Scala, or Java?
 
Category theory for beginners
Category theory for beginnersCategory theory for beginners
Category theory for beginners
 
How StorageMart Succeeds in Global & Local Search
How StorageMart Succeeds in Global & Local SearchHow StorageMart Succeeds in Global & Local Search
How StorageMart Succeeds in Global & Local Search
 
Airbnb tech talk: Levi Weintraub on webkit
Airbnb tech talk: Levi Weintraub on webkitAirbnb tech talk: Levi Weintraub on webkit
Airbnb tech talk: Levi Weintraub on webkit
 
Domain Modeling in a Functional World
Domain Modeling in a Functional WorldDomain Modeling in a Functional World
Domain Modeling in a Functional World
 
PISA 2015 - Volume I: Excellence and Equity in Education and Volume II: Poli...
PISA 2015 - Volume I: Excellence and Equity in Education and Volume II: Poli...PISA 2015 - Volume I: Excellence and Equity in Education and Volume II: Poli...
PISA 2015 - Volume I: Excellence and Equity in Education and Volume II: Poli...
 
Lancement de PISA 2015 en France
Lancement de PISA 2015 en FranceLancement de PISA 2015 en France
Lancement de PISA 2015 en France
 
Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)Functional Programming Patterns (BuildStuff '14)
Functional Programming Patterns (BuildStuff '14)
 
The power of creative collaboration
The power of creative collaborationThe power of creative collaboration
The power of creative collaboration
 
3 Ingredients to Spice Up Your Content Marketing
3 Ingredients to Spice Up Your Content Marketing3 Ingredients to Spice Up Your Content Marketing
3 Ingredients to Spice Up Your Content Marketing
 
Beyond the Gig Economy: How New Technologies Are Reshaping the Future of Work
Beyond the Gig Economy: How New Technologies Are Reshaping the Future of WorkBeyond the Gig Economy: How New Technologies Are Reshaping the Future of Work
Beyond the Gig Economy: How New Technologies Are Reshaping the Future of Work
 

Dernier

( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
nilamkumrai
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
Diya Sharma
 

Dernier (20)

Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...Top Rated  Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
Top Rated Pune Call Girls Daund ⟟ 6297143586 ⟟ Call Me For Genuine Sex Servi...
 
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
( Pune ) VIP Baner Call Girls 🎗️ 9352988975 Sizzling | Escorts | Girls Are Re...
 
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...Katraj ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For S...
Katraj ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For S...
 
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Pollachi 7001035870 Whatsapp Number, 24/07 Booking
 
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providersMoving Beyond Twitter/X and Facebook - Social Media for local news providers
Moving Beyond Twitter/X and Facebook - Social Media for local news providers
 
Real Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirtReal Men Wear Diapers T Shirts sweatshirt
Real Men Wear Diapers T Shirts sweatshirt
 
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort ServiceCall Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
Call Girls in Prashant Vihar, Delhi 💯 Call Us 🔝9953056974 🔝 Escort Service
 
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
Russian Call Girls in %(+971524965298  )#  Call Girls in DubaiRussian Call Girls in %(+971524965298  )#  Call Girls in Dubai
Russian Call Girls in %(+971524965298 )# Call Girls in Dubai
 
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts ServiceReal Escorts in Al Nahda +971524965298 Dubai Escorts Service
Real Escorts in Al Nahda +971524965298 Dubai Escorts Service
 
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
₹5.5k {Cash Payment}New Friends Colony Call Girls In [Delhi NIHARIKA] 🔝|97111...
 
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
Call Girls Sangvi Call Me 7737669865 Budget Friendly No Advance BookingCall G...
 
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft DatingDubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
Dubai Call Girls Milky O525547819 Call Girls Dubai Soft Dating
 
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...Russian Call Girls Pune  (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
Russian Call Girls Pune (Adult Only) 8005736733 Escort Service 24x7 Cash Pay...
 
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
VVVIP Call Girls In Connaught Place ➡️ Delhi ➡️ 9999965857 🚀 No Advance 24HRS...
 
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
𓀤Call On 7877925207 𓀤 Ahmedguda Call Girls Hot Model With Sexy Bhabi Ready Fo...
 
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...(+971568250507  ))#  Young Call Girls  in Ajman  By Pakistani Call Girls  in ...
(+971568250507 ))# Young Call Girls in Ajman By Pakistani Call Girls in ...
 
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
Hire↠Young Call Girls in Tilak nagar (Delhi) ☎️ 9205541914 ☎️ Independent Esc...
 
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
Call Now ☎ 8264348440 !! Call Girls in Shahpur Jat Escort Service Delhi N.C.R.
 
Al Barsha Night Partner +0567686026 Call Girls Dubai
Al Barsha Night Partner +0567686026 Call Girls  DubaiAl Barsha Night Partner +0567686026 Call Girls  Dubai
Al Barsha Night Partner +0567686026 Call Girls Dubai
 
Enjoy Night⚡Call Girls Samalka Delhi >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Samalka Delhi >༒8448380779 Escort ServiceEnjoy Night⚡Call Girls Samalka Delhi >༒8448380779 Escort Service
Enjoy Night⚡Call Girls Samalka Delhi >༒8448380779 Escort Service
 

End of-rails-wids

  • 2. THE ILLUSION OF STABLE APIS @APOTONICK
  • 15. “Most Rails developers do not write object-oriented Ruby code. They write MVC-oriented Ruby code by putting models and controllers in the expected locations. It takes 2-3 years before developers realize: “Rails is just Ruby.” -- Mike Perham
  • 21. class User < ActiveRecord::Base validates :name, length: 20 validates :email, format: email validates :age, numericality: true
  • 22. class User < ActiveRecord::Base validates :name, length: 20 validates :email, format: email validates :age, numericality: true User.create( name: “RISE!”, email: “rise@” age: 21 )
  • 23. class User < ActiveRecord::Base validates :name, length: 20 validates :email, format: email validates :age, numericality: true
  • 24. class User < ActiveRecord::Base validates :name, length: 20 validates :email, format: email validates :age, numericality: true
  • 25. class User < ActiveRecord::Base validates :name, length: 20 validates :email, format: email validates :age, numericality: true User.create( name: “RISE! This user is by ADMIN!”, email: “rise@” age: 21 )
  • 26. class User < ActiveRecord::Base validates :name, length: 20 validates :email, format: email validates :age, numericality: true User.create( name: “RISE! This user is by ADMIN!”, email: “rise@” age: 21 )
  • 27. class User < ActiveRecord::Base validates :name, length: 20, unless: → { creator_is_admin? } validates :email, format: email validates :age, numericality: true User.create( name: “RISE! This user is by ADMIN!”, email: “rise@” age: 21 )
  • 32. defmodule User do use Ecto.Schema import Ecto.Changeset schema "users" do field :name field :email field :age, :integer end def changeset(user, params :empty) do user |> cast(params, ~w(name email), ~w(age)) |> validate_format(:email, ~r/@/) |> validate_inclusion(:age, 18..100) |> unique_constraint(:email) end end
  • 34. defmodule User do use Ecto.Schema import Ecto.Changeset schema "users" do field :name field :email field :age, :integer end def changeset(user, params :empty) do user |> cast(params, ~w(name email), ~w(age)) |> validate_format(:email, ~r/@/) |> validate_inclusion(:age, 18..100) |> unique_constraint(:email) end end
  • 35. defmodule User do use Ecto.Schema import Ecto.Changeset schema "users" do field :name field :email field :age, :integer end def changeset(user, params :empty) do user |> cast(params, ~w(name email), ~w(age)) |> validate_format(:email, ~r/@/) |> validate_inclusion(:age, 18..100) |> unique_constraint(:email) end end
  • 39. class User::Create < Trailblazer::Operation model User contract do property :name property :email property :age, type: Integer validates :email, format: email validates :age, inclusion: 1..200 end def process(params) validate(params) do contract.save end end end
  • 41. class User::Create < Trailblazer::Operation model User contract do property :name property :email property :age, type: Integer validates :email, format: email validates :age, inclusion: 1..200 end def process(params) validate(params) do contract.save end end end
  • 42. class User::Create < Trailblazer::Operation model User contract do property :name property :email property :age, type: Integer validates :email, format: email validates :age, inclusion: 1..200 end def process(params) validate(params) do contract.save end end end