Posts

Showing posts from November, 2008

Rails Rumble, Apprenticeship, and a Running Website

Image
Apprenticeship is a big part of Obtiva (the consultancy where I work) so I introduced my friend Leah to Obtiva, they hit it off, and now she's an apprentice in the studio. Now apprenticeship at Obtiva is a paid, billable position. She's pairing everyday on a medium sized Rails business skill development project and learning a lot, but what just blew me away was the development of the "Run. Track. Run." project. Leah is a runner and for years she's been talking about how she'd like to create a decent running website that could import Gamin GPS data and produce useful graphs for runners. Apparently all the sites out there plot every single point of data returned from the GPS device, with little-to-no smoothing, and so the graphs are extremely noisy and hard to read. Wouldn't it be great if an actual marathon runner designed a website for runners? At which point I would usually say: "Yeah, that's a great idea -- we should do that someday....

If you use Mocha and RSpec then read this

I like RSpec, but I'm not a huge fan of it's built in mocking framework. So, when I have the choice, I swap it out for Mocha. However, I really miss mock_model. If you haven't used it, mock_model is an RSpec method where you pass in an ActiveRecord object and it stubs out a whole bunch AR magic so you don't have to. This is crazy useful when testing controllers because when you controller has a line like this: redirect_to(@model) I don't want to dig through a ton of Rails code to figure out what I need to stub on this model, I just want it to work. But I just found out that Mislav Marohnić has written a plugin that implements mock_model for Mocha -- so now I can get the best of both worlds. You can find it here: http://github.com/mislav/rspec-rails-mocha Thanks Mislav.

Naked Hashes are Trouble

So I had this form in a Rails view that needed some changes so, amongst other things, I changed this: form_tag(:action => 'search') to this: form_tag(:action => 'show', :method => :get) I had noticed that the show and search methods essentially did the same thing (and had the same views) -- which I why I refactored. However, when I made the change I got a 500. I was using restful routes and this form needed to be a get -- which I thought I had indicated. But I had not -- what should have put in the view was this: form_tag({:action => 'show'}, {:method => :get}) There's this idiom in Ruby where we don't put curly braces around hashes if we don't need to, but I've consistently lost a bunch of time to mistakes like the one above. So I'm thinking about explicitly denoting hashes with curly braces in my future Ruby code just to improve intentionality.

Photos from Ruby Conf 2008

Image
The Omni Resort was beautiful -- this was our view during lunch: I liked the Hotel but everything was very expensive. Breakfast buffet? 20 bucks. Awesome (really good bacon) but still 20 bucks. Dinner? 40-50 bucks. Cab ride there from the airport? 80 bucks. There was a tanning bed convention being held right next door. They got a security guard in front of their door while we did not. The next 2 pics are of the lazy river. I did a couple of laps (assisted by the current) and it was very nice. A fountain and one of the many pools. During the Matz Q&A my friend and fellow Obtivan Andy Maleh got up and asked some questions.

Ruby Conf 2008 Last Day

A wonderful, awful idea: ruby in the browser (and oh by the way it actually works!) by Christopher Nelson Chris thinks that while Javascript is an excellent programming language, he likes choices so why not provide people with the option to run Ruby in the browser? Also, while programming rich web apps he found that oftentimes he ended up with business objects in Javascript and in duplicate objects in Ruby. Not very DRY. He wanted to be able to use his Ruby logic server-side and in the browser. Two ideas that didn't work out: JRuby - the java security manager stopped him from doing just about anything Silverlight wasn't available for his operating system when he started the project Rubyjs is what he ended up using. Rubyjs is a ruby compiler that uses ParseTree to produce javascript. http://github.com/superchris/rubyjs The translation is, of course, not without some changes: Strings become Immutable strings Procs become Functions Hashes becomes custom hash object Chris then...

Ruby Conf 2008 Second Afternoon/Evening

What Every Rubyist Should Know About Threads by Jim Weirich Concurrency is becoming bigger as computers get more cores. If you look at a graph of clock speed they flattened out in 2003. Past performance gains: clock speed (not so much anymore) execution optimize cache results So if clock speed is not going up at a rapid pace anymore, now what?: hyperthreading multicore (the new saviour) caching Applications will need to be concurrent to exploit multicore machines. 100 CPU machines are on the horizon. Race conditions are trouble: If thread one has this: shared_variable += 1 And thread two wants to do the same thing: shared_variable += 1 What if the first thread looks up the shared_variable and find that it's 25 but before it can change it the second thread reads the value (still 25 because it hasn't changed). Now the first thread will add one (shared_variable becomes 26) and write the result back to memory, then the second thread will add one to the...

Ruby Conf 2008 Second Morning

Aristotle and the art of software development by Jonathan Dahl How do you identify a good programmer? Jon says Ethics. Ethics is about how you live your entire life. He thinks the what makes a good software developer and what makes a good person have parallels in their answers. Kant -- Only act on principles that you would like to become universal law. Kant would have loved Haskel. There are principles in software, but sometimes they conflict such as DRY vs write understandable code. DRYing something up can make it hard to read. John Stuart Mill Utilitarianism -- what matters is the effect of the action. The ends justify the means. However, It's hard to know whether the effects will be good ahead of time. The Pragmatic Programmer is a good outcome of Utilitarianism. But Utilitarianism may lead to sloppy code and processes. Or the Cowboy coder. Aristotle - ethics as virtue. The person is the important part. For Aristotle: ethics == a life well lived == happiness == virt...

Ruby Conf 2008 First Evening

Better Hacking With Training Wheels by Joe Martinez "We all have a stake in each other" -- we use each other's code in many, many libraries. What automatically checks the quality of our code? Joe wants to encode rules in a standard way (called wheels) so that you could drop it into Training Wheels and it would enforce your rules on the code. People who write new libraries could include a wheels directory in their library which would offer suggestions. Interesting idea -- on my current project we've be having problems with people calling destroy_all on an ActiveRecord class for no good reason. We could define a rule that shoots out a warning every time you do that. http://github.com/capitalist/training-wheels NeverBlock, trivial non-blocking IO for Ruby by W. Idris Yasser "Neverblock enables concurrent DB and network access without thew need to change the program flow" Which is awesome. Idris said that the Evented model is good but you must adjust your co...

Ruby Conf 2008 First Afternoon

Image
I was thinking today that most people design their talk to last 50-55 minutes but I've noticed that conferences have shorter and shorter times slots. 40 minutes + 5 for questions is becoming the standard. So the end slides tend to go by pretty fast. Another thought: Print the ID badge for the conference on both sides. Exactly the same information on both sides. Fully 50% of the people at Ruby Conf have their badges turned around to the white side and when I can't remember their names (even though we were just introduced) I can't cheat because all I see is a stupid white rectangle. Somehow GLSEC managed to figure this out, why can't other conferences? JRuby: What, Why, How...Try It Now by Tom Enebo and Charlie Nutter Why JRuby? Well the JVM is awesome. 15 quadriliion man years of work or something. 15 quadriliion Sun man years can't be wrong, right? They have declared that Ruby 1.8 is "done" (again) and 1.9 mode can be triggered with a flag. Full ...

Ruby Conf 2008 First Morning

Woke up 15 seconds before my alarm went off again today. Perhaps I'm a little keyed up? Keynote - Matz "Reasons behind Ruby" Matz's presentation started out with the question: Why Ruby? He asked why even though Ruby has lots of problems, like all languages, why do we love it? Which is interesting. I've seen Matz talk a few time now and he always talks about the love of languages. The idea of loving what you do is never far from his mind. When Matz was young, his first computer was a pocket computer in 1980 -- only 1400 steps allowed. Only 150 memory places. And the Language was BASIC. Later he found Lisp and it was the opposite of everything in Basic -- total freedom to do just about anything. And he loved it. That was, however, before he started using Lisp. When he started using Lisp in practice, he wasn't having a good time. Basically Matz felt that Basic took all the power from him, but Lisp gave too much back. He wanted to have a framework to ...

Great Lakes Software Excellence Conference

What a nice conference! Emphasis on nice. First Joel Adams, chair of Computer science at Calvin College, got up and welcomed us. Calvin College is where GLSEC was held and it looks so shiny and new I wondered if it had just been constructed. I stayed in a room the was about 200 feet from where I gave my talk. Then the mayor of Grand Rapids, George Heartwell, gave us software dudes a nice little welcome speech. He implored us to see downtown Grand Rapids and then talked a lot about jobs and growth. I know Michigan has had hard times, but from the looks of the airport and Calvin College (which is about as scientific a survey as it gets) Grand Rapids must be a city on the grooooow. The opening Keynote was given by Michael Cloran who is the the CEO of Interactions. He started off with a live demo of the "Service Factory." He spoke, through his phone, to a computer and it parsed his voice and answered his questions. It was scary impressive. Typical line from the extended ...

Here I am in Grand Rapids, MI

Flew in on election night for the Great Lakes Software Excellence Conference . I'll be giving my metrics talk tomorrow and then I'm off to Orlando, FL to give that talk at Ruby Conf . GLSEC is more of an XP/Agile/Process conference and I'm excited to be attending. The last time I was at a similar conference was XP/AU (Extreme Programming/Agile Universe) in 2004 when I was an apprentice at Object Mentor . I was just about to go back to my job as a high school physics teacher, but I did have an application in at ThoughtWorks. Ah, memories.