Displaying articles with tag

Found an excellent Abstract Factory pattern example

Posted by admin, Tue Jan 31 09:16:25 UTC 2006

I was hunting for a decent example of the Abstract Factory Pattern for ruby, and eventually stumbled across this gem:

Modular Architectures with Ruby

Summary Any reasonably complex end-user application is going to require some sort of customization and enhancement for effective deployment. This article shows one way to create a modular architecture as a way of leaving the door open for advanced users or consultants who want to extend the functionality without modifying the source.

Now I just wish everyone who was writing about patterns in Ruby could do as excellent a job as Jack has done here.

0 comments | Filed Under: | Tags:

Oops. Good thing I only had one user.

Posted by admin, Fri Jan 27 11:33:05 UTC 2006

Dump or Slurp YAML Reference Data (and Fixtures) | Ruby on Rails for Newbies

Sometimes you need to save data and use it again when you deploy a server or continue a project on a different machine.I wrote a plugin for ActiveRecord that lets you do this easily.
I really liked the idea of this plugin, but it could be a little more robust.

Just make sure that the first thing you try is “User.dump_to_file”. I used the “User.to_fixture” first, then I tried the “User.load_from_file”. And I got a nice users fixture file (which wiped out my existing fixture file without asking), and then…

$ script/runner "User.load_from_file"/usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/runner.rb:27: ./script/../config/../vendor/plugins/ar_fixtures/lib/ar_fixtures.rb:12:in `initialize': No such file or directory - /Users/lori/rails/test/db/users.yml (Errno::ENOENT) from ./script/../config/../vendor/plugins/ar_fixtures/lib/ar_fixtures.rb:12:in `load_from_file' from (eval):1 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `eval' from /usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/lib/commands/runner.rb:27 from /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require' from /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.2.5/lib/active_support/dependencies.rb:214:in `require' from script/runner:3 Lo and behold, it wiped out my USERS table. Oops.

0 comments | Filed Under: | Tags:

There are no new developers

Posted by admin, Fri Jan 27 09:45:26 UTC 2006

This article is entertaining… and frightening in it’s own way.

Hacknot – The A to Z of Programmer Predilictions

Sometimes I fancy that I have met them all. There will be no new developers for me to work with in future – only the reanimated ghosts of projects past. The same quirks and foibles that I’ve endured in the past will haunt me the rest of my days.

I recognized all too many of these characters. You will, too. It is sad, however, that there was only one female in the entire bunch. Really. I know that there are a lot more male programmers, but < 4% female? Come on. Get real.

0 comments | Filed Under: | Tags:

I knew there was a reason I hated the "m_" naming convention

Posted by admin, Fri Aug 27 18:52:28 UTC 2004

For years, I’ve been diligently erasing all traces of pre- and post-fix naming conventions from the source code under my control. I’ve always hated it. The argument I most commonly make for this is that, IMO, it makes the code less readable. Now, in a happy coincidence, I have been reminded about this topic, when I have actual proof to point at to back it up.

Now, “readable” is a very subjective term. Some people would insist that the prefix “m_” provides additional semantic meaning to the field, telling you that you are dealing with a class field instead of a parameter or local variable. In Java, so does “this.”. Others would add tags like “str” to the beginnings of every String field name. Again, yes, it adds semantic meaning, but any decent IDE will provide the same information in several different forms (tooltips, find definition, etc) without the extra baggage.

So, what about this proof? Consider the following:

Aoccdrnig to rsaerech, it dseon’t mttear in waht odrer the ltteers in a wrod are, the olny iroptmant tihng is taht the fsirt and lsat lteetr be at the rghit pclae. The rset can be a taottl mses and you can sitll raed it wouthit any perbolms.

Now, I hope you see where I am going. The real problem with all these pre- and post-fix notations is that they screw up that first/last letter recognition that seems to be hard-wired into readers of the English language, mostly because of some redundancy features of English. (See the links at the bottom of this post for more information about this.) So, there you have it. Proof that readability in your code is diminished by the use of pre- and post-fix naming conventions.

So let’s all get out there and start improving the readability of our code. JBuilder has some nice Rename Refactorings to help. ;-)

References Comments from a researcher at Cambridge A letter purportedly from the original researcher of the topic

And thanks to Anders for the inspiration from his new CafePress shop.

0 comments | Filed Under: | Tags: