SlideShare a Scribd company logo
1 of 43
Download to read offline
Loading...
Markdown vs. MongoDB
 A Journey through bleeding edge
          technologies
        for the NeXT Web
RubyMotion vs. Backbone
 A Journey through bleeding edge
          technologies
        for the NeXT Web
Rails Views
     for the
OO-savvy Rubyist
M

        V




    C
V




C
Look at: Rails current implementation
def show
 @post = Post.find(params[:id])
 @title = @post.title
end
<h1><%= @post.title %></h1>
<p><%= @post.body %></p>
<html>
 <head><title><%= @title %></title></head>
 <body><%= yield %></body>
</html>
And tell me boy, what‘s wrong
                    with my @ivars




My name‘s Guybrush threepwood.     I‘m new in town
Matz told me their only for Object‘s internal state
Who‘s in charge here?
Nice talking to you.
So how should
I use @ivars?
When you design a class, you decide
what internal state it has and also
decide how that state is to appear on
the outside (to users of your class).
The internal state is held in instance
variables. The external state is
exposed through methods we‘re call-
ing attributes.
Dave Thomas,
Programming Ruby
Deep in the Rails source...
# Define some internal variables that
# should not be propagated to the view.
self.protected_instance_variables = [
  :@_status, :@_headers, :@_params, :@_env,
  :@_response, :@_request, :@_view_runtime,
  :@_stream, :@_url_options, :@_action_has_layout
]
# Define some internal variables that
# should not be propagated to the view.
self.protected_instance_variables = [
  :@_status, :@_headers, :@_params, :@_env,
  :@_response, :@_request, :@_view_runtime,
  :@_stream, :@_url_options, :@_action_has_layout
]
protected instance variables
protected - instance - variables
And tell me boy, what ya
                 doing about this?




I‘ll stick with "helper_method".
Give me some "decent_exposure"?
It‘s "obviews"!
I‘m made of rubber, you‘re made of glue.
helper_method
pros: rails standard
cons: verbose, bad semantics,
class level
helper_method
pros: rails standard
cons: verbose, bad semantics,
class level
helper_method
pros: rails standard
cons: verbose, bad semantics,
class level
decent_exposure
pros: easy syntax, good defaults
cons: class level
decent_exposure
pros: easy syntax, good defaults
cons: class level
decent_exposure
pros: easy syntax, good defaults
cons: class level
obviews
pros: easy syntax, action level
cons: unpublished
obviews
pros: easy syntax, action level
cons: unpublished
obviews
pros: easy syntax, action level
cons: unpublished!
We want examples!
We want examples!




class PostsController < ApplicationController
 expose :posts
 def posts; Post.all; end
end
We want examples!




def show
 expose post
end
def post; posts.find(params[:id]) end
We want examples!




def show
 expose post: posts.find(params[:id])
end
We want examples!




<h1><%= pos title %></h1>
           t.
<p><%= post.body %></p>
Obviews
Obviews
on rubygems shipping today!
Thank you !1
twitter:   @elia
github:    @elia
blog:      dev.mikamai.com
blog:      elia.schito.me


                     MIKAMAI


 No monkeys were harmed during
    the making of this keynote
twitter:   @elia
github:    @elia
blog:      dev.mikamai.com
blog:      elia.schito.me


                     MIKAMAI


 No monkeys were harmed during
    the making of this keynote

More Related Content

What's hot

Copycopter Presentation by Joe Ferris at BostonRB
Copycopter Presentation by Joe Ferris at BostonRBCopycopter Presentation by Joe Ferris at BostonRB
Copycopter Presentation by Joe Ferris at BostonRB
bostonrb
 
Behavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with BehatBehavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with Behat
imoneytech
 
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
Bruce Li
 

What's hot (20)

MidwestJS Zero to Testing
MidwestJS Zero to TestingMidwestJS Zero to Testing
MidwestJS Zero to Testing
 
Copycopter Presentation by Joe Ferris at BostonRB
Copycopter Presentation by Joe Ferris at BostonRBCopycopter Presentation by Joe Ferris at BostonRB
Copycopter Presentation by Joe Ferris at BostonRB
 
You're Doing It Wrong
You're Doing It WrongYou're Doing It Wrong
You're Doing It Wrong
 
Ruby on Rails - UNISO
Ruby on Rails - UNISORuby on Rails - UNISO
Ruby on Rails - UNISO
 
Scaling Complexity in WordPress Enterprise Apps
Scaling Complexity in WordPress Enterprise AppsScaling Complexity in WordPress Enterprise Apps
Scaling Complexity in WordPress Enterprise Apps
 
Behavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with BehatBehavior Driven Development - How To Start with Behat
Behavior Driven Development - How To Start with Behat
 
Unit Tests Aren't Enough
Unit Tests Aren't EnoughUnit Tests Aren't Enough
Unit Tests Aren't Enough
 
Rails-3-app-auto-generator-20100817
Rails-3-app-auto-generator-20100817Rails-3-app-auto-generator-20100817
Rails-3-app-auto-generator-20100817
 
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
Make your Rails console AWESOME (Ruby SG meetup 2016-03-29)
 
RSpec. Part 2
RSpec. Part 2RSpec. Part 2
RSpec. Part 2
 
Rails Awesome Email
Rails Awesome EmailRails Awesome Email
Rails Awesome Email
 
RSpec. Part 1
RSpec. Part 1RSpec. Part 1
RSpec. Part 1
 
Performance
PerformancePerformance
Performance
 
Haml in 5 minutes
Haml in 5 minutesHaml in 5 minutes
Haml in 5 minutes
 
Tests in Javascript using Jasmine and Testacular
Tests in Javascript using Jasmine and TestacularTests in Javascript using Jasmine and Testacular
Tests in Javascript using Jasmine and Testacular
 
Reasons To Love Ruby
Reasons To Love RubyReasons To Love Ruby
Reasons To Love Ruby
 
Mistakes
MistakesMistakes
Mistakes
 
Mistakes I've made in Ruby and Rails
Mistakes I've made in Ruby and RailsMistakes I've made in Ruby and Rails
Mistakes I've made in Ruby and Rails
 
Concurrent PHP in the Etsy API
Concurrent PHP in the Etsy APIConcurrent PHP in the Etsy API
Concurrent PHP in the Etsy API
 
Telling Stories With RSpec
Telling Stories With RSpecTelling Stories With RSpec
Telling Stories With RSpec
 

Similar to Rails OO views

Similar to Rails OO views (20)

Writing Software not Code with Cucumber
Writing Software not Code with CucumberWriting Software not Code with Cucumber
Writing Software not Code with Cucumber
 
Introduction à Ruby
Introduction à RubyIntroduction à Ruby
Introduction à Ruby
 
RoR 101: Session 2
RoR 101: Session 2RoR 101: Session 2
RoR 101: Session 2
 
OOScss Architecture For Rails Apps
OOScss Architecture For Rails AppsOOScss Architecture For Rails Apps
OOScss Architecture For Rails Apps
 
Elixir Elevated: The Ups and Downs of OTP at ElixirConf2014
Elixir Elevated: The Ups and Downs of OTP at ElixirConf2014Elixir Elevated: The Ups and Downs of OTP at ElixirConf2014
Elixir Elevated: The Ups and Downs of OTP at ElixirConf2014
 
NinjaScript 2010-10-14
NinjaScript 2010-10-14NinjaScript 2010-10-14
NinjaScript 2010-10-14
 
Ruby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails 3.1: Let's bring the fun back into web programingRuby on Rails 3.1: Let's bring the fun back into web programing
Ruby on Rails 3.1: Let's bring the fun back into web programing
 
Ruby/Rails
Ruby/RailsRuby/Rails
Ruby/Rails
 
Ruby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developer
 
Ruby on Rails from the other side of the tracks
Ruby on Rails from the other side of the tracksRuby on Rails from the other side of the tracks
Ruby on Rails from the other side of the tracks
 
ruby on rails pitfalls
ruby on rails pitfallsruby on rails pitfalls
ruby on rails pitfalls
 
Free The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own DomainFree The Enterprise With Ruby & Master Your Own Domain
Free The Enterprise With Ruby & Master Your Own Domain
 
Ruby On Rails Pitfalls
Ruby On Rails PitfallsRuby On Rails Pitfalls
Ruby On Rails Pitfalls
 
Ruby on Rails at PROMPT ISEL '11
Ruby on Rails at PROMPT ISEL '11Ruby on Rails at PROMPT ISEL '11
Ruby on Rails at PROMPT ISEL '11
 
Ruby For Startups
Ruby For StartupsRuby For Startups
Ruby For Startups
 
Ruby on rails integration testing with minitest and capybara
Ruby on rails integration testing with minitest and capybaraRuby on rails integration testing with minitest and capybara
Ruby on rails integration testing with minitest and capybara
 
Diazo: Bridging Designers and Programmers
Diazo: Bridging Designers and ProgrammersDiazo: Bridging Designers and Programmers
Diazo: Bridging Designers and Programmers
 
Testing web APIs
Testing web APIsTesting web APIs
Testing web APIs
 
Pourquoi Ruby on Rails ça déchire ?
Pourquoi Ruby on Rails ça déchire ?Pourquoi Ruby on Rails ça déchire ?
Pourquoi Ruby on Rails ça déchire ?
 
Pourquoi ruby et rails déchirent
Pourquoi ruby et rails déchirentPourquoi ruby et rails déchirent
Pourquoi ruby et rails déchirent
 

Recently uploaded

Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Recently uploaded (20)

Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 

Rails OO views