Archive for the ‘ruby on rails’ Category

Metaprogramming JavaScript with Prototype

Thursday, April 5th, 2007

Controlling the DOM is everything for a JavaScript coder. The DOM itself is unruly, like a bull facing a matador. It doesn’t like to be tamed, prodded, and definately does like to get told what to do when JavaScript is written poorly. For most, the DOM wins and the lowely JavaScripter has little to do but hack up the code and Just Make It Work. Well, as with anything in life from relationships to a car, just making it work, sucks.

Several years ago, I was asked to dynamically update select fields (aka dropdown boxes) and conditionally present data based on the intial select field value. Simple enough, eh? A little javascript, a little php, the beginnings of an Ajax app for sure. While it wasn’t around at the time, I could have used some Metaprogramming to solve the problem. In its place, I wrote what I thought at the time was really clean javascript and PHP to perform the task. Only now, I know I was wrong all along. Granted, it worked as a solution and its still running today flawlessly for the client, however, I could have done it better. Like anyone worth their salt, I’m a perfectionist and an idealist, which makes for a very very picky programmer.

Adamlogic has tweaked prototype to developed an elegant solution to my very problem. I can’t believe it, but this is dead sexy [pdf]. Adamlogic’s usage of prototype to make JavaScript programming solve realworld problems with real world syntax is just so perfect.

The benefits read like a dream for a programmer who cares:
* Seperate “What” From “How”
* Reusable
* Self-Documenting (reallly?)
* Easy to Maintain (!)

but the big one is

  • Chain methods together in english language syntax.

Stringing methods like this, like passing objects as params to a method, is powerful indeed. This along could have solved a month of code.

show('US-state-field').when('country').is('United States');

Low Pro

Sunday, October 29th, 2006

Hey, you! You use prototype, right? Don’t love the event handling? Checkout Low Pro from Dan Webb. Plenty of additional functionality and fixes that makes prototype more of a joy.

Heavensent: Assembla

Sunday, October 29th, 2006

Any developer worth their salt uses three basic tools:

  1. Concurrent Versioning
  2. Issue \ Bug Tracking
  3. Project Mgmt Tools

For many, the top choices are Subversion (svn), Trac, and Basecamp, respectively. I consider these tools to be the holy trinity of professional software development, as they stay out of the way and let you do what you need to do. The best of breed tools these might be, but the only one that does it right is Basecamp. Why? Cause they make it pleasently easy to setup and use. Its all hosted for you, so the pain of installation and configuration is taken away.

For ease of use, including the install and config process, the other tools fall woefully short. I’ve had issues with installing svn and trac, to say the least. From misconfigured swig files to faulty apache configurations, I was becoming bald by pulling out my hair. Trac is especially hidious to install and configure (mostly configure), whereas svn slightly less unnerving, yet both tools are so complelling in the open source community that they’ve quickly become a defacto standard for software developers.

With the obvious large audience in hand, it saddens me that the developers of these tools don’t really do much in the way to ease the the install\config process. For example, Trac has just released their 0.10 release with minimal documentation on upgrading or fresh installation.

Frustrated as I was, I was thrilled to find Assembla, a group of developers that collect these rouge best of breed tools and allow you to use them in a hosted platform, ala Basecamp. Config? Nope. Cost? Nada. Just sign up, send invites to your teammates, and you’ve got yourself svn and trac ramped up and ready to go.

So what’s the catch? From what I’ve gathered thus far, I cannot find a fault. The service is build around a Ruby on Rails mgmt web app, with features that tie directly into your totally configurable install of trac\svn. Want typo? Its there too! Will this stick around is the the big question? New companies and projects come and go faster than you can say web2.0. Security, above all else, is the primary concern. Again, they seem to have it locked down. Trac is setup with .htpasswd apache files, so you’ve got auth for trac. They could do more to support sensitve areas by serving up under https. For now, I’m going to get started on trac’ing my bugs, which is all I wanted to do in the first place.

Overall, assembla is a godsend.

Dear Trac and Subversion,

Wednesday, August 30th, 2006

Your installation process is horrific. Your documentation is vague and obtuse, leaving out details that are vital to properly implementing your software. Generally, you’ve made my day a nightmare and I don’t like you for it. I have a good feeling its blind luck that some get their repos working properly, cause your documentation fails miserably.

signed,
average user.