🕷 zenspider.com

by ryan davis

Looking for the Ruby Quickref?

CanadaOnRails, day 1, shared notes

Published 2006-04-13 @ 19:13

Tagged rails, thoughts

Canada On Rails, day 1. These notes were created with the great SubEthaEdit and many people joining in sharing minds. I love this tool. I think it is amazing and really good during conferences. I’ve copied the notes in with full editing marks so you can see how people interacted. Below are the participants and the notes are behind the cut:

Come in, say hi:

** Sorted by Last Name **

[name deleted by request] - [deleted] - boy - with cool hat (in icon at least)

Paul Coyle - deprecated

Ryan Davis - aka zenspider - current projects: rubyholic, ruby2c, metaruby, ParseTree, RubyInline, ZenTest, RubyObfuscator - independent consultant

Bruce Fletcher - broke through my firewall! 1337! Intranet PHP stuff for a small Vancouver company.

Miles K. Forrest - Big tall guy in black jacket. Enjoying the conference (yay!), so did my boss (ooo!) who just gave me my walkin’ papers (boo!). Guess I’ll be flipping burgers soon. needs to learn to sort

Tim Glen - php app developer from calgary. I work for a little company called nonfiction studios. We use some rails concepts in our framework like AJAX and other view helpers. Wanting to use more rails. Oh yah. Hi everyone!

Kalin Harvey - self-employed IT consulting, doing more dev work recently, Vancouver

Eric Hodel - drbrain - drbrain@segment7.net - all that stuff ^^ - MogileFS, rails_analyzer_tools - 43 Things - Face in snow icon

Brian Muckian - unemployed, out cast from popular development er…platforms, ruby fanatic, rails fanboy….I’m sure I’ve been called worse

Ken Pratt - http://kenpratt.net/ - doing RoR apps at EA, finishing up a CS degree at UBC, and leaving for 10 weeks of backpacking around europe in 16 days!

Brasten Sager - rjsassertions – random stuff. Recently became full-time Ruby developer. (yay!) (Will be wearing a black Apple-logo baseball cap all conference long. Come say hi.) - eric wants to talk to you about rjsassertions

Graeme Worthy - pleasant fello. likes linux and .. sushi.. and .. pizza. looks hot with a moustache. looks like a used car dealer when wearing a 70s suit.

Nathan Youngman - http://nathany.com - Mac-geek, ColdFusion programmer (6 years), ruby nuby

Ryan Davis’ Document - I’ll be putting this up soon. blog.zenspider.com

Joe O'Brein  
 Service Oriented Architecture  
Kyle Shank  
= Tooling Rails - RadRails (Eclipse-based)  
Eclipse: Developed at IBM ~ 30,000 users  
 cross platform  
Gateway drug for Java developers  
 == Frameworks & Tools  
Bad frameworks can elicit bad tooling  
   lots of synchronizing code, can't tell what does what  
 J2EE requires tooling  
   Without causes quality to suffer  
 Rails doesn't require tooling  
== Control  
   Don't want to make users give up control  
   Need to understand what's going on  
   "I can only do what I can drag and drop"  
== Control Focus  
 Many "RAD" applications take away control  
  --that little joke is a big reason I haven't taken it seriously  
95% code generation and synchronization leads to 5% comprehension  
 Less code not no code  
 Putting developer in the loop [?]  
== Remember  
 Software is actually supposed to make our lives easier  
 == Features  
* Server tooling  
 * data tooling  
 * testing support  
 * rhtml editor  
 * fast controller/view/test switching  
 * generators view  
 * svn support  
 * more...  
== Demo  
   Generates stuff  
   test/controller/view switching  
   Database view (pulls database.yml config)  
== Tooling  
 * Migrations  
     Relationships kept in individual models  
     Structure kept in set of migration steps  
 * [?]  
 == Tooling 2  
 * Refactoring  
 * Renaming or changing in a namespace  
 == Road to Dorothy  
 * visual breakpoint debugging  
 * better code assistance  
 * Quality migration tooling  
 * plugins and engines  
 * rake task discovery and execution  
 * generator discovery  
 * Capistrano recipe discovery  
 == Commercial tooling  
 * CEO's talking about partnership  
 * The space is open  
 * commercial sector will not adapt until ther is something to pay for  
 * MS thinks we're just going to tool rails for Visual Studio (that's just dumb)  
 == ...  
 Can't run tests from view??  
 Bar is wrong, should be proportional :(  
 = Behavior Driven Driven Development  
 Dave Astels - dastels@daveastels.com - http://www.daveastels.com  
 == Dave  
 Test driven development - a practical guide  
 a practicle guide to XP  
 == BDD  
 == TDD  
 Most people that claim to be doing TDD aren't doing it well.  
 BDD makes it better.  
== XP - test everything  
      test everything first  
      write tests before code  
== Units - a vague term, can be many things, let's move forward to ...  
== Behavior  
 Programs do something  
Not the state that your code is in  
 == Sapir-Whorf  
 How you talk has a big effect on you - how you view the world, how you think  
In linguistics, the Sapir–Whorf hypothesis (SWH) states that there is a systematic relationship between the grammatical categories of the language a person speaks and how that person both understands the world and behaves in it  
 Testing lets you verify what you want, now you want to talk about what the behavior of a program should be.  
 NO more TDD, BDD  
 behaviour driven development.  
 dan north, thoughtworks uk.  
 == State  
Classic mistakes when performing TDD  
   Do this thing, check some variables  
     No business putting those things in that spot  
    Problem : you are testing the implementation  
     Tests break  
 Don't test private methods, part of the implementation detail  
   private methods come from extraction  
     extraction was performed test-driven  
 == Behavior  
State leads to Behaviour, better tests  
[what's a mock?? it is a fake object that tests what methods get called on it]  
Call a method, what does it return?  
== Expectations.  
  specify behaviour by setting expenctions.  
 == rSpec  
 "You could probably do it really well in Ruby"  
 xUnit wasn't good enough, didn't fit, new framework was needed.  
   assert_equal(expected, actual)  
   actual.should.equal expected  
 Even better in Smalltalk:  
   actual should equal: expected  
     [so true!, I want my free colons]  
 More assertions  
   should.equal 5  
   should.not.equal 5  
   should.be.close 5.1, 0.5  
   should.be obj  
   should.not.be obj  
   should.satisfy { |obj| ... }  
  should.not.satisfy {|obj| ...}  
 Pattern Matching:  
 Arbitrary Predicate:  
   where predicate? is defined on the target  
Eg. titanic.should.sink   
     given that the OceanLiner has #sink?  
 Forced Failure:  
 Called on the execution context, not on the target object.  
   should.raise Exception  
   should.not.raise Execpition  
where the target is a Proc  
 Now the target object in this case is a proc.  
 Lambda.should raise... or soemthing.  
   should.throw :symbol  
   should.not.throw :symbol  
   should.not.throw # no symbol  
 Ancestor Class  
   should.be.a.kind.of klass  
   should.not.be.a.kind.of klass  
maps to parent classes..   
  Should.respond.to method_name  
   should.not.repsond.to method_name  
 == How to Express These  
   context"context name" do   
Inside that block you write specifcations  
   setup do end  
   teardown do end  
Example test:  
   context "South facing obelisk"  
   setup do  
     @board.place 'Gold Obelisk A5 South'  
     @piece = @board.at 'A5'  
   specify "Obelisk do  
   specify "South" do  
     @piece.should.be.facing 'South'  
 == Mocking API  
   m = mock 'mock name'  
 will be auto-verified  
 Expecting a method:  
   should.recieve :name  
   at.least :once  
   at.least :twice  
   with :no_args  
   with :any_args  
  with(arg1, arg2, ...)  
   with ..., :anything, ...  
   with ..., :boolean,   
   with ..., duck_type(:foo, bar), ...  
 Return values:  
   and.return value  
   and.return [v1, v2, ...]  
   should.receive :name do |arg1, arg2|  
 Becomes return value of the call, but mocks shouldn't have any logic, so don't do this.  
     .and.return [['a', 'b']]  
    .with ["a","b"]  
== Tools  
 Process specifications and genearte documentation  
spec [options](FILE|DIRECTORY)+  
   -o set output file  
   -v show more  
   -d generate doc  
 Convert Test::Unit tests to specifications  
test2spec [options] SRC [DEST]  
Process Specs  
 [look just like Test::Unit]  
4 contexts, 18 specifications, 0 failures  
 Verbose mode:  
 An empty stack  
 - should accept an item when set push  
 - should complain when sent top  
 - should complain when sent pop  
 Genaret docs:  
 # An empty stack  
 # * should accept an item when set push  
 # * should complain when sent top  
 # * should complain when sent pop  
 == Why Ruby?  
 Dynamic, productive, maleable, fun  
 Smalltalk, OO guy, didn't like C++, Java  
== Code, Questions, Discussion  
 Ordering in mocks?  not yet, but coming  
 DSL approach, more english-oriented. rSpec tests serve a documentation purpose.  
 gem install rspec  
= Test Driving the Rails  
 Steve Baker - srbaker  
Specification not Verification  
== Refactoring  
 Tests tell you when you've broken something, good feedback.  
 Tests tell you when you're done.  
 Decoupling means you don't have to worry about relationships stomping on each other  
 Gives you less code.  
Book on rails wiki - "A guide to testing the rails"  
 [blah blah blah rake test blah blah blah]  
 [I know a bunch about testing, so you guys should document this stuff]  
 write test, fail, fix, repeat  
 do the minimal work  
 Mocks - really stubs  
 "I laughed too after the crying was done."  
 rCov, ZenTest  
 "What's all this crap? [...] We don't have enough time to write unit tests."  
 "What is all that extra crap you're writing?"  
 "Your test suite will always point you in the right direction?"  
 "You're writing the minimal possible."  
 "Why is this a useful thing to be testing, it's not like it's not like that's something that's going to break." ... Well it's not going to break if you're doing unit tests.  
 "Arrogance Works"  
 "It may take you longer to write software, but you'll write software quicker — you'll write working software quicker..."  
Selenium is tasty - use it  
"the only way you're going to show how this is faster is have two projects 
running in parallel, and then change something and see who fixes it faster.." 
or something likes that  
David A Black  
<del>Ruby and the Rails Developer: Breaking through the Programming Glass Ceiling 
Meditations on the Ruby/Rails Ratio  
http://www.manning.com/black  (Ruby for Rails book)  
Rails is easy to work with.  
 Ruby is easy to work with.  
 Is it important to learn Ruby if you're using Rails?  
 (depends on your idea of ease/difficulty)  
 it's a wrong assumption to think of it as the easy one and the hard one.  
 Glass Ceiling Metaphor:   
 a glass cieling is there because someone puts it there.  
 you're under the impression that you are upwardly mobile, but someone else who makes the decisions doesn't.  
Ruby, in regard to rails, is mis-percieved in two ways:  
 ruby is too advanced, and too hard to use   
or, that ruby is too low level to be interesting, it's a building block, but it's a solved problem.  
 Ruby is not higher or lower than rails.  
 Ruby           2+2  
 ----  !=     -------  
 rails     Rocket Science  
(aside: "the takahashi method" <-- one word on the screen at a time)  
"Programming languages operate according to a principle that the language itself 
is just a means to an end and what you're doing is programming. that, in theory, 
it shouldn't matter what language you use since they all do essentially the same thing anyway."  
 i've always felt that one way to get a handle on the culture of programing languages is by analogy with musical instruments  
 music is music and it shouldn't matter what instrument you play.  
"People really do indentify very strongly with their instruments."  
 You're associate with a culture and a community and a repetoire.  
 People compete,   
 "My instrument is harder than your instrument"  
 Oh, you play that.. <sneer>  
 If someone plays the french horn, they don't sit around saying 'the viola sux'.  
 It should be "it's just a tool", but it somehow never is.  
 Anecdotal advocacy.  
 "I started using ruby, and almost immediately, i had something running. or. You should try rails, you'll have something running really quickly."  
 "The Art of the Violin" - DVD Documentary - mid-20th century string playing  
 "Rails is in the piano camp - it gets out of your way... All of the things that have been said about Rails, those things have been said for years about Ruby.  There is a real kinship, and it's no accident that rails was written in ruby. 
 "Sometimes instruments have commonalities that are not just the instrument themselves. There are threads running through them such as cellists and bassoonists - they are very different but we both play bass lines."  
 "That was a little bit of an aside............"  
 pull it uphill.  
 low lying.  
 rickety tower.  
 "I don't think I have a slide for this actually"  
 "Helper files help reduce the urge to put functions in code. everything has it's place. Knowing where things are likely to be and how they are likely to link"  
"You can sort of will things into being in Ruby - you can just sort of look at it and it undulates a little."  
 "What makes a great state is its being like a low-lying, down-flowing stream; it becomes the center to which all other states under heaven tend. . . ."  
 Classes can have methods +   
 Objects are instances of classes  
 Objects can have methods  
 "You find this interesting..."  
 Ruby love, ruby love ruby love rubylove  
 obj = Object.new  
 def obj.talk  
     puts "Hi!"  
 obj.talk # => Hi!  
 # Also basic -- object happens to be an instance of Class  
 myclass = Class.new  
 def myclass.talk  
     puts "Hi on behalf of this class!"  
 myclass.talk # => Hi on behalf of this class!  
 # same ides, but inside class defintion block  
 class MyClass  
     def MyClass.talk  
         puts "Hi on behalf of MyClass!"  
 MyClass.talk # => Hi on behalf of MyClass!  
What rails has done.. is quite complex, but what happens at the end of all this, is a return to simplicity.  
It's possible to tie ruby in knots, and expose that in the API, but done well, 
as in Rails, coming back to the simplicity of Ruby and strengthening it, makes 
it feel continuous with Ruby.  
 temporary site to buy book:  
 CanRails35 is a code for 35% off the paper book Ruby for Rails!  
Ruby for Rails is cheaper on Amazon without the discount code plus free shipping so no rush  
= Ajax on Rails  
 Amy Hoy  
You can't talk about AJAX without talking about Javascript. About a year ago, javascript was evil.. suddenly, javascript is cool.  
 1. Good Support - you can write js and it will run in all your major browsers  
 2. Professional Tools - people are treating is as a real language  
3. Publicity! - Buzz had a large part in bring javascript "back up"  
AJAX - a round trip to the server, without reloading.  
 Regular js is not ajax!!  
"Please only call it AJAX if you're hitting the server"  
 Regular request: Browser Request -> web srever -> rails app  
 Ajax Request: browser request -> web server -> rails app  
 ...They look the same, except the Ajax one is driven by JS  
and rails is...  
 freakin' sweet  
Rails + js = crazy delicious  
Sexy Preview  
 <%= link_to 'Fetch me kittens',  
             :controller => 'kittens',  
             :action => 'list'}  
 <%= link_to_remote "Fetch me kittens",  
                    :update => 'ajax_result',  
                    :url => { :controller => 'kittens', :action => 'list'} %>  
 <div id="ajax_result"></div>  
that code is turned into javascript  
On a form you are only adding :update => 'ajax_result'  
difference between the link code and submit code   
 Ruby JavaScript Templates  
Very cool, covered more in Thomas Fuch's talk tomorrow  
Really Awesome  
Like a view but spits out js.  
New in 1.1  
prior to 1.1 it is a plugin  
 she won't cover all the cool scriptaculous stuff   
  edit in place - scriptaculous helpers  
 what comes with rails that makes AJAX possible  
     Very cool because you can use it anywhere, is flexible  
     from thomas, which partially relies on prototype.  
     (as dhh mentioned, this will be plugin in future RoR)  
   rjs plugin  
    now with 1.1, or can d/l plugin for previous versions  
 with the exception of Rails frameworks suck so we don't need a framework for script...lous  
 to make the js work dont' forget the line that inlcudes your js in the app! (in layout file)  
<% javascript ...   
 js helpers namespaces:  
 Troubleshooting ajax  
the tools that you want:  
   firebug - really good stuff  
         one problem is if an erro causes a page reload you lose the errors  
             solution is to use the real js console  
   web developer extension for firefox  
 The web developer toolbar in IE crashes every 5 mintues  
 Amy has an excellent tutorial on autocomplete with scriptaculous  
 There are rake tasks that will allow you to update your js files.  
   $ rake -T | grep update  
   rake rails:update              # Update both scripts and public/javascripts from Rails  
   rake rails:update:javascripts  # Update your javascripts from your current rails install  
   rake rails:update:scripts      # Add new scripts to the application script/ directory  
 Amy is publishing "Ruby on Rails: A right brained guide" from the Pragmatic Programmers.  
 = Less technology - the ruby and rails revolution  
 Alex Bunadzic  
 Jooto, Inc.  
"I am clueless"  
"I am pre-emptive" [ gives Santana's guitar playing skills as both clueless and pre-emptive. 
Santana looks fooling with a guitar when not playing... awkward... and just 
before he joins in he goes fierce ]  
[this is a hard talk to track...]  
All of the software products he has experienced seem to ahve been built by carpenters.  
 What's wrong with this?  
 We don't need cabinets!  so what do we actually need?  
 A good parpenter will make sure something is well constructed.  
 a good Luthier [musical instrument maker], someone [Danny Ferrington--the best] who is making a guitar, will still do what a carpenter would try to do, but 
would look to make it loosely coupled.  It should be "at the verge of falling apart" to make the sweetest sound.  A loosely built cabinet would fal apart.  
 The loose pieces in a guitar vibrate and capture your style, body movement, style.  
A good guitar will respond to the person playing it, will adjust to that person's 
quirks, and would allow....   
[wabi-sabi note--missed it]  
 A good guitar will not be uptight, it will breath.  
Most software is too uptight, doesn't allow a coder to breath.  
 It's "industrial-strength". The software doesn't reach harmony with its user  
What we need is products that vibrate and breath and cooperate with us.  It 
will make us 'sing' when using it.  
 In this way software is similar to a musical instrument  
How do we do this?  
We need direct contact. It is very important  
 So long as we keep building softare indicrectly we will fail to be able to espress ourselves.  
Software doesn't allow us to express ourselves.  Crutches and wheelchairs are 
in our way, we need a direct means of expressing our intentions.  
 Memo to the machine: If I intend to accolmplish something in real life, I usually express my intentions by writing a memo. Works well because I'm not mystified by writing. If I try to write a memo to the machine, I end up being mystified.  
 "Do whot I mean, not what I tell you"  
The meaning of your memo is difficult for the machine to understand.  
 Tend to grossly mininterpret my intentions. We need to focus on a language that will bridge this gap. Want to be able to naturally write a memo to the machine.  
 What about errors? bugs? testing? defects?  Can't use a wishy-washy approach.  How do I test things? What's the real life equivalent of a test before sending mail to a client? Simple: Send it to the lawyer's office.  
To err is human, Mistakes happen.  But that's not a show-stopper. Why should it be a show-stopper 
for software? Of course there are certain memos/email that must be scrutinized. These are 
in the minority.  
 How do I write a memo to the machine? Embrace less technology.    
Industrialization and automation are behind us.  
 Realize the age of the smart servent. Replace the age of dumb machines.  Began when people realized that 'less code' was better than 'more code'  
This movement began with the realization that 'less code' is more desireable than more code.  
 Less is more.. yadda yadda yadda  
 Time for a wakeup call.  
If you want to continue enjoying your job it is time to wake up.  
Ruby and Rails resemble something made by a master luthier. Due to their focus of context (== common-sense)  
 "Context beats consistency"  
 Both ruby and rails have a strong bias against foolish consistency. Allows them to focus on building a smart servant instead of a bunch of hard 
to manage dumb service.  
 What is a smart servant?  
Smart servants are a mind like entity that has the ability to avoid foolish consistency, being sensitive to context.  
 Most software isn't sensitive to context. they suck. we need better.  
 Application is the middle man between info proc sys and user. App translates intentions between user and system.  
 Similar situation existied not that long ago, when people were illiterate. We had middle-men who'd write for you if you needed it. Today most ppl are literate. Real world's need for software brokerage is going away.  
Once the barriers of talking directly to the underlying information processing system get sufficiently lowered, people will begin bypassing applications  
 For that to happen we need languages that are much more expressive than ruby  
 but ruby is a good start  
 when that happens we'll find ourselves writings scripts to the machines  
 rigid apps will never go away, but in everyday affairs we will learn to ease up a bit.  
 [[hey guys, thanks this was great, there is talk of going for beer and food in teh campfire, do join]]  
 [[ this is being blogged... right now ]]