RailsConf 2014 - Day 1

Part 1 of 4


Keynote: Writing Software (ConFreaks)

David Heinemeier Hansson (Twitter)

Stop writing knee-jerk tests.

Test-first development naturally leads to dependency injection.

Dependency injection is the worst thing on the planet.

You can make anything fast if it doesn't work.


Ultra Light and Maintainable Rails Wizards

Andy Maleh

http://andymaleh.blogspot.com/
http://bigastronaut.com/

https://github.com/andymaleh/ultra_light_wizard

Wizards should be as simple as possible. Don't duplicate paper forms.

Example: EarlyShares

Goals

  • persist progress at each step
  • rest
  • mvc
  • oo
  • non-functional requirements
    • productivity
    • maintainablity
    • performance
    • security

Approaches

  • one controller per step
    • each controller saves and redirect to next step
    • duplicate code
    • controller manages steps
  • one action/presenter per step
    • not restful
  • session accumulation
    • not scalable
  • hidden value accumulation
    • persist values in hidden form fields
    • .net webforms approach
    • not secure
  • state machine
    • model manages steps
    • presentation logic in model
  • gems

Wizards implement the builder design pattern

  • each step is a partial view of the model

Object Oriented Views (Confreaks)

Andrew Warner (Twitter)

https://github.com/rapgenius/perspectives
https://rubygems.org/gems/perspectives

Holy Grail

Best possible user experience combined with the best possible developer experience.

  • no full page reloads
  • feels like desktop/native
  • developer friendly framework
  • don't repeat yourself
  • mostly single language (Ruby, JavaScript, Rip)
  • search engine friendly

Closest framework today is Rendr by AirBnB

Also duplicate code, TurboLinks and front-end clients (AngularJS, Ember)

Perspectives (new approach)

lowest common denominator == dumbest possible template

  • separation of concerns
  • testing (just testing plain ruby objects)
  • easy caching

Make An Event Of It

Jason Clark (Twitter)

https://github.com/jasonclark/simple_events
https://github.com/cyprus/mutations

Where are we going?

  • pattern
  • coupling
  • meechanics
  • responsibility

Notifier
Eventing System
[ Subscriber ]

Internal Coupling


Concerns, Decorators, Presenters, Service Objects, Helpers: Help Me Decide! (ConFreaks)

Justin Gordon

https://github.com/justin808/fat-code-refactoring-techniques

Guidelines

  • methods less than 5 lines
  • classes less than 100 lines
  • one instance variable per view

Objectives

  • dry
  • easy to test
  • clarity
  • easy to find
  • easy to change

Advanced AREL: When ActiveRecord Just Isn't Enough (Confreaks)

Cameron Dutro (Twitter)

http://www.scuttle.io/

Stop writing SQL in AREL queries!

  • have to know specific, potentially non-portable, syntax
  • no syntax checking
  • not chainable
  • what does ? mean?

Examples

Post.select(Post.arel_table[:visitors].count).to_sql
Post.select(Post.arel_table[:visitors].min).to_sql
Post.select(Post.arel_table[:visitors].max).to_sql
Post.select(Post.arel_table[:visitors].sum).to_sql

Post.select(Arel.star).to_sql

Post.select(:id).from(Post....ast)

Post.where(Post[:title].eq('some string')).to_sql
Post.where(Post[:some_number].lteq(42)).to_sql
Post.where(Post[:title].eq('some string').and(Post[:id].in(22, 23))).to_sql

Post.joins(:comment).where(:id => 42).to_sql
Post.joins(:comment).where(Post[:id].eq(42)).to_sql
Post.joins(Comment.joins(:posts).join_sources).where(Post[:id].eq(42)).to_sql

Keynote: What Happens To Everyone, When Everyone Learns To Code? (ConFreaks)

Farrah Bostic (Twitter)

Fantastic talk, must watch video.