tag:blogger.com,1999:blog-192390472024-03-08T00:36:42.124+00:00made of stoneThe blog of Rahoul Baruah from <a href="http://www.3hv.co.uk/">3hv Ltd</a>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.comBlogger216125tag:blogger.com,1999:blog-19239047.post-39553330904265988702008-03-03T21:14:00.004+00:002009-01-03T19:04:06.481+00:00See ya<script language="javascript">setTimeout('window.location="http://www.3hv.co.uk/blog";', 1000);</script><br /><br />I started this blog over two years ago, charting my experiences using Ruby on Rails on IIS. <br /><br />As you may have noticed, I don't do that anymore. Not that I have any great hatred for IIS/Windows/Microsoft - it's just not as much fun as staying on the Linux side of the fence. <br /><br />While I still love coding in Rails, I'm not doing that much out of the ordinary any more. All the interesting stuff is at a business level - so instead I'm going to concentrate on my <a href="http://blog.3hv.co.uk">business blog</a> (you can <a href="http://feeds.feedburner.com/3hv">subscribe here</a> if you want). There'll still be Rails stuff posted there, but intermingled with marketing, sales and finance. <br /><br />So thank you Blogger, thank you IIS, thank you dear readers. It's been a blast. See you at <a href="http://www.3hv.co.uk/">3hv</a>.<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-31902115301658058582008-02-08T19:20:00.000+00:002008-02-08T19:22:48.971+00:00The Return of DjangoI see the Django folks have been hitting my "<a href="http://made-of-stone.blogspot.com/2006/01/rails-on-iis-revisited.html">Installing Rails under IIS</a>" article pretty hard recently. <br /><br />All I can say is "good luck guys" - I'm glad I don't have to do that at the moment. Did MS ever finish their FastCGI implementation?<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-2662708546237295282008-02-08T17:14:00.000+00:002008-02-08T17:22:22.537+00:00Spamming Northpack for fun and profitLeeds Ruby Thing was last night - it was a fun night out with a good number of people (about 20-25 turned up). John has <a href="http://www.flickr.com/groups/leeds-ruby-thing/">posted some photos</a>. <br /><br />But mainly this post is to annoy <a href="http://www.thehodge.co.uk/">Dominic</a> when it appears on the <a href="http://www.northpack.co.uk/">Northpack</a> feeds list.<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-83514264173932341212008-02-06T22:44:00.000+00:002008-02-06T22:56:38.112+00:00What's wrong with RSpec?I don't know. <br /><br />I've tried, really tried to like it. <br /><br />And I don't know why I don't. <br /><br />Something just doesn't <span style="font-style: italic;">feel</span> right.<br /><br /><ul><li>It's testing. </li><li>It's test-first. </li><li>It's test as specification. </li><li>It reads like English. </li></ul><br />All things I like.<br /><br />But it feels wrong, wrong, wrong. <br /><br />Anyone have any ideas why?<br /><br />PS: I was going to call this post "Arse-pec" but I thought that was a bit harsh.<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com2tag:blogger.com,1999:blog-19239047.post-17834400127019308372008-02-06T09:46:00.001+00:002008-02-06T09:56:20.432+00:00ASCII changes cause strange artifactsWhy does <a href="http://www.squeak.org/">Squeak</a> use the underscore _ as an assignment character[1]? <br /><br />Because in 1963 the ASCII code for _ <a href="http://methodsandmessages.vox.com/library/post/why-the-long-face-er-underscore.html?_c=feed-atom">actually represented a left arrow</a> - which makes perfect sense as an assignment operator. <br /><br /><br />[1] (as well as := which Pascal folks will recognise)<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-77314406172957645672008-02-04T12:37:00.000+00:002008-02-04T12:39:21.762+00:00The Leeds Ruby ThingExpertly named by £2000/hour marketing consultants, the <a href="http://upcoming.yahoo.com/event/423116">Leeds Ruby Thing</a> is taking place at the Victoria Hotel at 7pm on Thursday the 7th February. I probably can't get there till 9ish though. <br /><br />Join us and talk about Ruby. And drink beer.<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-50263724250599743672008-02-03T20:06:00.001+00:002008-02-03T20:14:18.499+00:00Microhoo!I stopped reading FSJ a while back but he certainly has the best <a href="http://fakesteve.blogspot.com/2008/02/ballmer-im-completely-out-of-ideas.html">analysis of the proposed Microhoo! deal</a> I've seen so far. It's also worth noting that nothing has actually happened yet.<br /><br />Via <a href="http://imran.typepad.com/">Imran Ali</a> on <a href="http://www.twitter.com/">Twitter</a>.<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-57932949521413209582008-01-30T22:42:00.000+00:002008-01-30T22:44:26.767+00:00Dominic<a href="http://www.thehodge.co.uk/">Dominic</a> "The Hodge" Hodgson is doing an SEO experiment - aiming at 26 in Google. So this post is for him.<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-30251115987947291172008-01-30T15:11:00.000+00:002008-01-30T21:31:06.241+00:00Why hashes as named parameters in Ruby are a good thingBack when I used to do lots of Sql Server Transact-SQL, I used to dislike named parameters. They annoyed me and I only used them when I had a stored procedure with a large number of parameters, some of which were optional. (As an aside, we had procs with parameter lists running into twenty or thiry, some of which were optional and some were mandatory - it was a nightmare and named parameters were essential in those cases). <br /><br />Odd though. Named parameters turn out to be one of my favourite Ruby features - even though Ruby doesn't have them. And, even odder, they used to be one of my favourite Smalltalk features (Smalltalk has always had them). <br /><br />Today, my learned colleague was on a roll. Fantastic design ideas were flowing. One issue he was busy solving was handling an image at multiple sizes. The application had an ActiveRecord class representing a file - and if the file were an image then it could store that image at multiple resolutions. He proposed something along the lines of this: <tt>my_file.required_size(width, height)</tt> - the implementation would then hunt through the related images at various sizes, pick out the correct one and return it. This meant that a view would have code looking something like this: <br /><br /><tt>image_tag my_image.required_size(400, 300).web_url, :alt => h(my_image.description)</tt>. <br /><br />His proposed implementation was fine - but I suggested renaming the method <tt>at</tt> - so you could write <tt>my_file.at 400, :by => 300</tt>. <br /><br />"<cite>But <b>at</b> doesn't explain the method's purpose</cite>" was the reply. "<cite>That's why you should name the second parameter and pass it as a hash</cite>" said I. This would make your view code look like this: <br /><br /><tt>image_tag my_image.at(400, :by => 300).web_url, :alt => h(my_image.description)</tt><br /><br />Personally, I think this is much easier to read and, with the named parameters, explains the intention of the <tt>at</tt> method perfectly (although the brackets spoil it a bit). <br /><br />The key difference between the two languages is that in Ruby, the method is named "<tt>at</tt>" and you call it as <tt>my_file.at 400, :by => 400</tt>. In Smalltalk, methods names <em>include the parameters</em> - so it is named "<tt>at: aWidth by: aHeight</tt>" (and you would call the method by writing <tt>myFile at: 400 by: 300.</tt>). <br /><br />The Smalltalk idiom of including the parameter names within the method name is much clearer at explaining the method's intention. And the very act of naming your parameters means you can apply much more meaningful <em>sentences</em> within your code - which is exactly what Alan Kay meant for us to do all those years ago. Don't you agree?<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-67858820946125502532008-01-28T21:05:00.000+00:002008-01-28T21:09:51.281+00:00Brightbox at NWRUG<a href="http://www.brightbox.co.uk/a/dplsk">Jeremy and John</a> will be speaking at the <a href="http://nwrug.org">North West Ruby User Group</a> tomorrow (Tuesday) about the <a href="http://blog.brightbox.co.uk/posts/brightbox-hits-the-road">business and technical challenges</a> of setting up a UK Rails-specific <a href="http://www.brightbox.co.uk/a/dplsk">hosting company</a>.<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-4628298782146913552008-01-23T12:12:00.001+00:002008-01-23T12:18:54.324+00:00Moving changes from one subversion repository to anotherI'm sure this is old hat to you svn experts but I've just figured it out. <br /><br />If you need to transfer a load of changes from one subversion repository to another (or you have an external developer helping you out on your open source project who has submitted a patch) this is what you need to do: <br /><br /><h2>Generate a Patch File</h2><br /><br />Move to your "source" working copy and run: <br /><br /><tt>svn diff -r REV > my_patch.txt</tt><br /><br />This finds all changes since revision number REV and places them in my_patch.txt. <br /><br /><h2>Apply a Patch File</h2><br /><br />Move to your "target" working copy and run: <br /><br /><tt>patch -p0 < my_patch.txt</tt><br /><br />This applies all the changes in my_patch.txt to your target working copy. Running <tt>svn status</tt> then shows all the files that have changed - you can then review the changes before an <tt>svn commit</tt> (of course crediting your developer in the comments).<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-53835870017664309962008-01-17T12:23:00.000+00:002008-01-18T10:10:19.087+00:00A (late) review of the yearIt's been a pretty monumental year for me - quitting the day job and doing this Rails business full-time. Plus, I've actually been blogging about it. So, a bit late, here are my favourite posts from last year. <br /><br /><a href="http://made-of-stone.blogspot.com/2007/08/unless-versus-if.html">unless versus if !</a> (absolutely the greatest piece of example code there is)<br /><a href="http://made-of-stone.blogspot.com/2007/05/great-features-you-see-great-features.html">Great Features you see, Great Features you don't</a><br /><a href="http://made-of-stone.blogspot.com/2007/04/markupbecomebeautiful.html">markup.become(:beautiful)</a><br /><a href="http://made-of-stone.blogspot.com/2007/11/death-to-professionalism.html">Death to Professionalism</a><br /><a href="http://made-of-stone.blogspot.com/2007/01/dealing-with-disaster.html">Dealing with Disaster</a> (Dreamhost take note)<br /><a href="http://made-of-stone.blogspot.com/2007/04/formtesthelper-and-ajax-update.html">form_test_helper and AJAX (Update)</a><br /><a href="http://made-of-stone.blogspot.com/2007/03/ruby-on-rails-is-macos-to-javanets.html">Ruby on Rails is the MacOS to Java/.Net's Windows</a><br /><a href="http://made-of-stone.blogspot.com/2007/10/infamous-iphone-sdk.html">The infamous iPhone SDK</a><br /><a href="http://made-of-stone.blogspot.com/2007/09/testing-for-unix-commands-on-path-in.html">Testing for Unix commands on the path in Ruby</a><br /><a href="http://www.fngtps.com/2006/10/http-authentication-in-os-x-is-broken">Safari, So Good, So What!</a> (just for the title, Megadeth fans)<br /><a href="http://made-of-stone.blogspot.com/2007/01/default-values-in-your-models.html">Default Values in your Models</a> (one of the most searched for posts on the blog)<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-9040410679921201752008-01-17T12:00:00.000+00:002008-01-28T21:05:26.536+00:00Geeeeeeeek UuuuuuuupAnother Wednesday in the middle of the month, another Geekup meeting in Leeds. <br /><br />I had a great time chatting with the <a href="https://www.brightbox.co.uk/a/dplsk">Brightbox</a> boys and taking photos of the <a href="http://www.northcrew.co.uk/">Northcrew</a>, in preparation for the launch of their two new sites - <a href="http://www.northcast.co.uk/">Northcast</a> and <a href="http://www.northpack.co.uk/">Northpack</a>. <br /><br />Thanks, as ever, to Deb and Rob for organising it. And the next one has Christian Heilmann talking about Javascript.<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-58988779658967354622008-01-07T20:54:00.000+00:002008-01-08T21:40:30.769+00:0010 Rules of Thumb to radically improve your Ruby on Rails code<a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjISyrANSMnSC2mZ6WWGfy8rDVh6hVE9QTLgbyT6i60xEnKuH8cw5KXBcUJ423pFABhz37Efwv5DxUIVcDQNDvEEouyS_fbaTLI3WQVxNGwSV14jF3PtGJ65z8jZRJJ4TjSyP-_/s1600-h/Picture+1.png"><img style="margin: 0pt 0pt 10px 10px; float: right; cursor: pointer;" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjISyrANSMnSC2mZ6WWGfy8rDVh6hVE9QTLgbyT6i60xEnKuH8cw5KXBcUJ423pFABhz37Efwv5DxUIVcDQNDvEEouyS_fbaTLI3WQVxNGwSV14jF3PtGJ65z8jZRJJ4TjSyP-_/s320/Picture+1.png" alt="" id="BLOGGER_PHOTO_ID_5153223753308168802" border="0" /></a><br />Ruby on Rails has generated a lot of hype over the last couple of years.<br /><br />This is a good thing - Rails is well-supported and well-understood.<br /><br />But it's also a bad thing.<br /><br />Lots of people read the "<span style="font-style: italic;">Agile Web Development</span>" book and then charge a fortune to develop RoR applications. <span style="font-weight: bold;">Badly</span>.<br /><br />I have seen some shocking projects, chock full of the type of spaghetti code that the Rails hype claims you cannot produce (of course this is nonsense - you can write shite in any language).<br /><br />Over the years I have developed a whole number of "rules of thumb" that I use to evaluate a project's code. These are subjective, inaccurate and open to interpretation. But taken as a whole they give you a pretty decent idea of the state of the code.<br /><br />And here they are:<br /><br /><span style="font-weight: bold;">rake stats</span><br /><br />Look at the ratio of code to tests.<br /><ul><li>More code than tests? Lose 10 points</li><li>Between 1:1 and 1:1.5? No points</li><li>Above 1:1.5? Gain 5 points</li></ul><span style="font-style: italic;">This test is pretty arbitrary. Just because you have lots of test code doesn't mean that the tests are any good. But </span>not<span style="font-style: italic;"> having lots of tests is bad. </span><br /><br /><span style="font-weight: bold;">Dependencies</span><br /><br />Is Rails and any required plugins installed into the vendor folder?<br /><ul><li>No? Lose 10 points</li><li>Yes? No points</li></ul><span style="font-style: italic;">It's incredibly easy to include the correct version of Rails and all your dependencies within your application tree. Making it easier to share your code with the rest of your team and taking uncertainty out of deployment. </span><br /><br /><span style="font-weight: bold;">rcov</span><br /><br />Is rcov pre-installed?<br /><ul><li>Yes? Gain 5 points</li></ul><span style="font-style: italic;">rcov is easy to install and pretty useful. </span><br /><br />What is the test coverage?<br /><ul><li>rcov won't work? Why not? Lose 10 points</li><li>More than 10% red? Lose 20 points</li><li>Less than 10% red? Lose 10 points</li><li>All green? Gain 10 points</li></ul><span style="font-style: italic;">This test is also pretty arbitrary. A green line, as above, doesn't mean that the test is any good. But a red line is always bad. </span><br /><br /><span style="font-weight: bold;">Migrations</span><br /><br />Can the database be built completely from migrations?<br /><ul><li>Yes? Gain 10 points</li><li>No? Why not? Lose 10 points</li></ul><span style="font-style: italic;">Databases are key to Rails development and migrations make them easy to share with your team and deploy to your server. </span><br /><br /><span style="font-weight: bold;">Logic in all the right places?</span><br /><br />Is there any application logic in the controllers?<br /><ul><li>Yes? Lose 10 points</li><li>No? Gain 10 points</li></ul><span style="font-style: italic;">Controllers are part of the user-interface, function specific and relatively difficult to reuse. Application logic belongs in the models where it can be accessed via the console, not just the web-server. </span><br /><br />Is there any application logic in the views?<br /><ul><li>Yes? Lose 10 points</li><li>No? Gain 5 points</li></ul><span style="font-style: italic;">Views are strictly user interface components - they should be primed by the controller so that the view has nearly all of its decisions made for it. </span><br /><br /><span style="font-weight: bold;">Warnings and Deprecations</span><br /><br />Are there any deprecation notices when running the tests or application?<br /><ul><li>Yes? Lose 5 points</li></ul><span style="font-style: italic;">Deprecation warnings mean that your code will probably stop working when you upgrade your version of Rails. </span><br /><br />Are there any warnings when running the tests or application?<br /><ul><li>Yes? Lose 20 points</li></ul><span style="font-style: italic;">Warnings are there for a reason. Pay attention to them - in most cases, it is purely laziness that keeps them there. </span><br /><br /><span style="font-weight: bold;">RDoc</span><br /><br />Do all the models have RDoc comments - a header describing the class and comments for each method?<br /><ul><li>Header comments? Gain 10 points</li><li>All method comments? Gain 10 points</li><li>Some method comments? Gain 5 points</li><li>No? Lose 10 points</li></ul>Do all the controllers have RDoc header comments describing their purpose?<br /><ul><li>Yes? Gain 5 points</li><li>No? Lose 5 points</li></ul>Do all the helper methods have RDoc method comments describing their purpose?<br /><ul><li>Yes? Gain 10 points</li><li>No? Lose 10 points</li></ul><span style="font-style: italic;">Ruby is easy to read and generally pretty easy to understand. That deals with explaining </span>what<span style="font-style: italic;"> your code does. But the point of the RDoc comments is to explain </span>why<span style="font-style: italic;"> it does it that way, which, arguably, is even more important. </span><br /><br /><span style="font-weight: bold;">Repeated Code </span><br /><br />Is there any repeated code? Are there similar pieces of code in multiple places that could be consolidated into a single parametrised method?<br /><ul><li>Yes? Lose 10 points</li></ul><span style="font-style: italic;">When writing code if you find yourself writing something similar to code you have already written then it is always worth moving it into a centralised method or class - either as a helper, a model or even a module. </span><br /><br /><span style="font-weight: bold;">Readability</span><br /><br />How readable is the code? Can you tell, at a glance, what the most complicated pieces of code do?<br /><ul><li>No? Lose 20 points</li><li>Yes? Gain 20 points</li></ul><span style="font-style: italic;">Unfortunately this one is pretty subjective. But, to my mind, code should read like English wherever possible. This may be sub-optimal - especially with regards to performance. It doesn't matter. You can go back, profile the code and optimise the slow bits (of course, your tests make sure that you aren't breaking any functionality). And when you optimise, keep the original (slow) code as a comment to explain what your unreadable (fast) code is doing. </span><br /><br /><span style="font-weight: bold;">Idioms </span><br /><br />Does the code use symbols as hash keys and (the equivalent of) enumerations?<br /><ul><li>Yes? Gain 10 points</li><li>No? Lose 10 points</li></ul><span style="font-style: italic;">Symbols are sort of like strings but are treated specially by the interpreter - sort of like a literal. Carefully used, they can also make your code more readable. </span><br /><br />Does the code pass objects to generate links?<br /><ul><li>Yes? Gain 5 points</li><li>No? Lose 5 points</li></ul><span style="font-style: italic;">HTTP is not object-orientated but Rails can at least pretend that it is. </span><br /><br />Writing this stuff down is strange. It takes things that often comes to me as a "gut feel" and documents and codifies it. Necessarily this means that there are things that I notice that I haven't written down here. Apologies - I will update the article as and when I think of them.<br /><br /><span style="font-weight: bold;">What use is this check-list? </span><br /><br />If you are worried about the state of your Rails project <a href="http://www.3hv.co.uk/">3hv</a> is planning a service where your code is evaluated against these criteria and you receive a detailed report with recommendations for improvement. Excellent for managers who are worried about progress, even better for developers just starting out on Rails. Details are still being finalised but <a href="http://www.3hv.co.uk/contact">contact me</a> if you are interested.<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-16221052826998848112007-12-30T17:47:00.000+00:002007-12-30T20:23:42.845+00:00Coding in EnglishI've been programming computers, professionally, for over eleven years now (and programming in general for over twenty). In that time, I've tried a number of different programming environments and languages.<br /><br />Delphi (Object Pascal),<br />Java (upto 1.4),<br />Smalltalk,<br />Ruby,<br />Python<br /><br />and<br /><br />C#,<br />Visual J++,<br />VBScript/Visual Basic,<br />Realbasic<br /><br />as well as<br /><br />Ansi C,<br />C++ (Borland C++ Builder, Visual C++, Ansi C++),<br />Objective-C (only a little bit),<br />PHP,<br />Lisp (at least some variant of it that was designed by someone at my university),<br />x86 assembler.<br /><br />The languages and environments I like are in the first group, the ones I dislike in the latter group and the middle group are "<span style="font-style: italic;">almost but not quite</span>". The question is what do they have in common?<br /><br />Simple: it is easy to make them read and write like English.<br /><br />Yeah, it's a bit subjective.<br /><br />You could argue that Java and C# belong in the same group (I'll get to that in a bit). But the last group are quite happy chucking weird syntactic pieces into the mix - it makes my head hurt trying to remember when you need a & and when you need a * in the C languages. I have to say that Ruby, at first, put me off with its @s and @@s.<br /><br />What about Java and C#? It has to be said that syntactically they are both very clean. But why is Java in the "good" group and C# in the "maybe" group? Because when I met Java it was cleaner than everything except Smalltalk. But when I met C# my frustration with static typing had boiled over. By the same token, Delphi now belongs in the "maybes" whereas, at the time, it was firmly in the "goods".<br /><br />But, overall, Ruby wins. Code like:<br /><pre><code><br />dave.punch george unless george.is_hard?<br /></code></pre> (I'll never tire of that example).<br /><br />Or:<br /><pre><code><br />using :lame do<br /> encode '/my/audio/file'<br />end<br /></code></pre> (a real bit of code that only executes the block if the given the 'lame' command is present within $PATH)<br /><br />Or:<br /><pre><code><br />hit nail, :with => hammer, :on => head, :at => :maximum_force<br /></code></pre><br />The latter is a pattern I often follow - using Ruby's hash as a way of building named parameters. This is something I learnt from Smalltalk, which was originally intended to be usable by seven year olds (<tt>hit: theNail :on theHead :at #maximumForce.</tt>). This makes the method definition look something like:<br /><pre><code><br />def hit object, options = {}<br /> using = options[:with] || my_default_implement<br /> where = options[:on] || my_default_area<br /> force = options[:at] || my_default_force<br /> ... some code ...<br />end<br /></code></pre><br />The key thing here is that the options keys do not match the actual variable names <span style="font-style: italic;">because they serve different purposes</span>. The options keys are for the <span style="font-style: italic;">users</span> of the method, the variable names for the <span style="font-style: italic;">implementors</span>.<br /><br />Likewise, Ruby's arrays combined with blocks give you a whole load of power in a very small amount of text. <br /><br />Given the choice of using <tt>Array#inject</tt> or writing something more verbose I will always go with the verbose. <br /><br /><pre><code><br />collection.inject(0) { | sum, obj | sum += obj.details.size }<br /></code></pre><br />versus:<br /><pre><code><br />total = 0<br />collection.each do | item |<br /> total += item.details.size<br />end<br />return total<br /></code></pre><br /><br />(OK - not the best example). But, to me, the intention of the second version is immediately apparent whereas the first takes a second of squinting to figure out. <br /><br />I was recently presented with something looking something like this:<br /><pre><code><br />sort{|a, b| index.collect{|i| (a[i] || 0) <=> (b[i] || 0))}.compact[0] || 0}<br /></code></pre><br />With apologies to the author, I'm still not sure what that does. <br /><br /><br />Readability is everything. Code spends longer in maintenance than development. And choosing your tools correctly can mean that, with minimal effort, your code can look like English.<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-73003413348394157652007-12-29T21:23:00.001+00:002007-12-29T21:30:09.041+00:00Nostalgia ain't what it used to beI gave away my iMac G3 a few weeks back. I wiped all my personal details off the machine and gave it to <a href="http://www.freecycle.org">Freecycle</a>. But in order to wipe my personal details I had to boot it into OS9 - and it has to be said that it's still better than OSX. <br /><br />A 500Mhz 512Mb G3 is more responsive (not necessarily faster) than my dual 2.3Ghz 2Gb MBP. <br /><br />The consistency of the UI, the simple rules (start at the top left and flow to bottom right - which is why the Apple menu and trash can are where they are) and the fact that you had acres of screen space at 1024 resolution. <br /><br />I miss both the machine and the OS. Sometimes progress isn't all it's made out to be.<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-11928023602115226892007-12-21T21:10:00.000+00:002007-12-21T21:11:51.075+00:00Test Driven DevelopmentTDD is quite easy. <a href="http://blog.3hv.co.uk/2007/12/21/implementing-a-task/">Write the tests first, make them pass, refactor</a>. So why aren't you doing it?<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-6569032541419105412007-12-21T15:37:00.001+00:002007-12-21T15:38:12.571+00:00Shameless self-promotionSome people have <a href="http://about.3hv.co.uk/showcase">recommended</a> me, so the 3hv site has been updated accordingly.<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-2793088663838503072007-12-20T22:15:00.000+00:002007-12-20T22:16:47.527+00:00Geeking upThanks to Deb and Rob for another Geekup. Weird beers, an iPhone and geektalk.<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-76036935578311864142007-12-17T09:31:00.000+00:002007-12-17T09:34:42.108+00:008 steps for fixing other people's code<a href="http://drnicwilliams.com/2007/06/01/8-steps-for-fixing-other-peoples-code/">How to submit patches</a> to other people's projects. <br /><br />And, of course: <br /><blockquote>If the project has a suite of test cases, please make an effort to add “failing test cases”. That is, add test cases that demonstrate the defect by failing</blockquote><div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-65336150423969464802007-12-15T19:42:00.000+00:002007-12-15T19:43:50.382+00:00Estimating a ProjectIt's not rocket science. It's a <a href="http://blog.3hv.co.uk/2007/12/15/estimating-a-project/">flowchart</a>.<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-69615836816502161242007-12-13T15:25:00.000+00:002008-01-14T16:09:46.668+00:00UK based Ruby on Rails HostingIf you're looking for a host for your Rails application I can recommend <a href="http://www.brightbox.co.uk/a/dplsk">Brightbox</a>.<br /><br />They offer Virtual Private Servers that are geared up for Ruby on Rails deployments (even down to supplying a <a href="http://rubyforge.org/projects/brightbox/">gem</a> to help you get started).<br /><br />They're nice guys, they know their stuff and they're based in the UK. So what are you waiting for?<br /><br />Disclosure: I have worked with them on their CMS and order processing system.<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-59961023172796152332007-12-13T15:02:00.000+00:002007-12-13T15:06:44.583+00:00Forking HellAs of today I am now forking this blog. <br /><br />All your Ruby and Rails based goodness will still be found here but everything business related will be found at my <a href="http://blog.3hv.co.uk/">company's blog</a>. Go on, <a href="http://blog.3hv.co.uk/feed">subscribe</a> to <a href="http://made-of-stone.blogspot.com/feeds/posts/default">both</a> of them.<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-3302624329284214632007-12-11T14:59:00.000+00:002007-12-11T15:05:54.198+00:00When Enterprise software will finally get respect<a href="http://www.blackfriarsinc.com/blog/2007/12/when-enterprise-software-will-finally">Blackfriars Marketing</a> commenting on Bill Gates' claim that Enterprise Software gets little respect (via the Wall Street Journal). <br /><br />As someone who has worked on 'business' and 'enterprise' software for most of my career (the difference being one of scale as far as I can see) I wholeheartedly agree. I got sick of being told that the user-interface was 'good enough'. Half a second of frustration quickly adds up if you are sat in front of an application for eight or more hours a day(*). <br /><br /><blockquote>especially when we confront real systems at work that increase workloads, enforce meaningless restrictions that don't help customers, and sport user interfaces that feel Kafka-esque in their user hostility. It's not surprising that enterprise software gets no respect; it is surprising that there aren't more cases of employees throwing their computers out windows in frustration.</blockquote><br /><br />(*) Incidentally, that always used to be my response when people said that Windows had achieved parity with the Mac user experience. Give two experienced users a tight deadline, one on a Mac, the other on Windows, and see who swears the most. Frustration => Unhappiness => Staff Turnover (for the buyer) and No Repeat Sales (for the vendor)<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0tag:blogger.com,1999:blog-19239047.post-88212297362226778232007-12-10T16:36:00.001+00:002007-12-10T16:49:06.537+00:00Weird behaviour involving controllers, modules, namespaces and functional testsWeird one here. <br /><br />I was working on some code that had controllers within a namespace (<tt>Admin::ThingyController</tt>). The controller descended from an <tt>Admin::BaseController</tt>. And <tt>Admin::BaseController</tt> included a module (<tt>include GenericStuff</tt>), which in turn was defined within the <tt>Admin</tt> namespace. <br /><br />So far, so good. <br /><br />The code-base was actually somebody elses and the time came for me to add a new controller into the <tt>Admin</tt> namespace. So away I went: <tt>ruby script/generate controller admin/another_controller</tt>, editing the file so that <tt>Admin::AnotherController</tt> descends from <tt>Admin::BaseController</tt>. <br /><br />Then, as I do, I filled out my functional tests, made them pass (<tt>ruby test/functional/admin/another_controller_test.rb</tt>) and then built up some (reasonably) nice views and examined them in my browser. <br /><br />All good. The views worked, the tests passed, the controller did what it was supposed to. <br /><br />One final check before committing to svn - <tt>rake</tt>. Bugger. A whole load of failures. What have I broken? Eh? It's <tt>AnotherController</tt> that is failing. Check it in the browser. All good. Check the test individually. Row of dots. Try <tt>rake test:functionals</tt>. Blam!<br /><br />To cut a long story short (actually the story is pretty short, it was the investigation that was long) the cause was the included module in the BaseController. What is particularly weird is that it was only <tt>AnotherController</tt> that had the failures, even though all the controllers within the admin namespace were defined the same way. Adding the new controller had upset the rake loader somehow. <br /><br />And the fix? Change the include in <tt>BaseController</tt> from <tt>include GenericStuff</tt> to <tt>include Admin::GenericStuff</tt> (even though the admin prefix is not necessary as both GenericStuff and BaseController are within the same namespace). Now they all work - tests, rake and in the browser.<div class="blogger-post-footer">Web Development in Ruby on Rails at http://www.3hv.co.uk/
Execution is Everything</div>Bazhttp://www.blogger.com/profile/08540002478471101536noreply@blogger.com0