Fun with named scopes in Rails

One of the features that I definitely had no idea about when I first learned Rails was named_scope. I went back at look a look at some of the old projects I had worked on I frequently found myself writing a bunch of extra finder conditions or methods in order to achieve that goal.

That is a relatively simple example, but since these conditions are used frequently I can improve upon this by using named scopes. Named scopes allow you to encapsulate some finder arguments into a simple, chain-able, and efficient methods. Here is what the named scope definitions and finder looks like:

While these could be defined as standard methods, you loose a lot of the power and flexibility which named scopes provides. For example, with named scopes I can add in additional arguments or conditions to any of the above methods. For example:

If you are using Rails 2.3 they have added a feature called scoped_by which will dynamically generate a lot of the boiler-plate scopes that you would need.

If you aren't using Rails 2.3 or aren't crazy about that syntax there is also a Ruby gem which provides a lot of the same functionality in an arguably more elegant manner. Its called Pacecar and it made by the guys over at Thoughtbot. Using Pacecar the above example would look like:

That looks a lot more elegant to me. So get out there and start using some named scopes.

Ballmers iPhone stunt could hurt Microsoft long-term

Just about a week ago news came out that Microsoft CEO Steve Ballmer had a strong reaction to an employee who tried to take his picture using an iPhone. At the company meeting in Safeco field, an employee was trying to take his picture when Ballmer grabbed the device, said a few remarks about it, and then pretended to stomp it into the ground.

Anybody who has ever seen Ballmer speak knows that he is a passionate guy. While most people can appreciate the passion and enthusiasm that he brings to the table, there are times when this can bite you. I think this was one of those times. Let me explain...

Prior to last week, Microsoft had actually made some inroads on the iPhone with the release of the SeaDragon and Microsoft Tag apps. While I would not consider these everyday-use type apps, they were a pretty clear step in embracing the iPhone platform and utilizing it strengths. I played with the SeaDragon app quite a bit and it really is a perfect marriage of the two technologies (e.g. pinching to zoom on the large images, etc).

In my eyes those inroads have now been left be left to rot as a result of Ballmers actions. Think about it this way, say you are a Microsoftie who has a great idea for an app which really showcases a Microsoft technology, would you be willing to stand up in front of Ballmer and pitch the idea? That idea had better be an incredibly good one with a ton of potential otherwise...

Who does this really hurt? Search. Contrary to what many people believed, Microsoft has really made a big comeback in the Search space with Bing. In fact it was this past August that Bing surpassed 10% marketshare which is a pretty big milestone in its growth along with a nice month over month improvement. Currently desktop search dominates the market, but anyone with a little bit of foresight will tell you that mobile search is and will continue to be a big growth area in the near future. Unfortunately, Bing's presence in the mobile market (particularly the iPhone) is...shall we say...weak. Yeah, they have a mobile site, but thats about it. Unlike Google and Yahoo!, Bing has no search app as far as I can tell. Furthermore you can't even set Bing to your default search engine (Google/Yahoo! are currently the only options).

Now if your Bing fighting for each point of marketshare, dumping tons of money on the "search overload" ads, why not get a few developers together and have them make a Bing iPhone app? One word, Ballmer.

When being anti-web is just not cool: Fever RSS

I have been a pretty avid user of RSS for a few years now and as a technology it is awesome. Just about everybody knows that pulling technologies are much more efficient then pushing and thats what makes it possible to consume so much more information. To show you what I mean, looking at my Google Reader I am currently subscribed to 80 feeds and in the past 30 days I've read over 6,000 articles (~200/day). While I really like RSS, one of the things I really found missing was the lack of intelligence of RSS readers. Instead of just displaying me all the information in reverse chronological order, how about displaying them based on how interested I am in that article or feed. Sure that is a little more complicated, but in a world where theres tons of information it is a lot more efficient. The reality is that it is just a big text mining and ranking problem with the data right there in front of you, so get cracking. I'm genuinely surprised Google hasn't tried to tackle this problem since it is right in their wheel house, but that is a whole other story.

Over the past year or so I have been keeping my ear to the ground for new RSS readers which try to do what was described above. Then about a month a go a discovered a tool which was almost exactly what I was thinking about called Fever. Using the temperature as a nice metaphor for the things you are interested in, fever displays the information aggregated from your feeds based on how frequently an article is linked to. It is basically a personalized version of Techmeme. Looking at the screen shots it has a really nice design aesthetic which I can definitely appreciate and it even has an iPhone app. At this point I am looking for the nearest input box, chalk one up on the conversion rate I'm ready to use this thing. All jazzed up to get my RSS on and I'm greeted by the ugly credit card monster. An RSS reader that costs money, scoff. But given how nice it seems I figured I might consider spending a few bucks a month on such a nice tool. So how much does it cost? $30. That seemed like an odd price, and it is, the reason being that fever isn't a hosted service, its a desktop client. You plop down your $30 bucks for a license (you remember those things right?) get yourself the software and use away right? Not so fast, if you take a look at the answers section you will see the following:

What are the server requirements for Fever?
Fever requires a Unix-like server (no IIS) running Apache, PHP 4.2.3+ (preferably compiled with mbstring and GD with PNG support) and MySQL 3.23+.

Thats not your standard desktop software requirements list (e.g. dual-core processor, 1GB of ram) by a long shot. Instead, fever requires that you set up your own LAMP stack to host the stinking thing. While the software is nice, there is no way in hell I'm gonna set up and administer a server just to run it, thats just too much. Even with a variety of cheap VPS hosts out there, its just not worth the effort and cost.

After I gave it some thought, fever really is the perfect app for hosting. Its way to much of a pain for a single user to setup, requirements are fairly high, and you can pretty easily do database multi-tenanting. I looked around online to see if anyone was hosting fever but came up completely empty. Being a bit of an entrepreneur I figured this is something I could pretty easily setup, so I went ahead and contacted the developer to see if he was interesting in allowing others to host fever as a hosted service. The terse response I got was "I have no interest in offering Fever as a hosted application or in partnering with another party to offer Fever as a hosted application." Harsh.

Needless to say I was pretty disappointed. Not only did I loose out on the opportunity to make a cool little hosting business, but I lost the opportunity to actually use a really cool product. This is where I get back to the title of why being anti-web and why it is so uncool. There was a time when having software licenses and hardware requirements were all the norm, during that time many of todays software mega-corps (e.g. Microsoft, Oracle) were built. Unfortunately for them and much to the benefit to users everywhere, that time is rapidly coming to an end. Desktop software is simply a pain for everyone involved. Developers don't like it since its incredible difficult to make software for the different platforms plus all the complication of pushing out updates to all the users. Users don't like it because they have to fork over an arm and a leg to buy it and the onus to deal with updating it falls on them. Now I'm not going to fall of the deep end and say that all software is going to be hosted, but there is little reason that a significant portion of all the software can't live in the cloud. There are always exceptions for things like operating systems and really complex and resource heavy software but those only make up a minuscule fraction of the software in use today.

The moral of the story is that if you are making cool software that people want to use, do everything in your power to allow them to use it. If you want to charge, thats fine, but give it to users in the way that they want to use it and if you don't have the resources or desire to do that, by all means allow others to do so.