Archive for December, 2005

Here's hoping Radrails takes off as a Ruby on Rails IDE

Tuesday, December 13th, 2005

In my
hunt for a good Ruby IDE I’ve tried almost all of the Ruby IDE’s I
could find. After using a variety of them I’ve lately been switching
between Radrails and JEdit with the Ruby plugin.
As a Java programmer I have a natural bias towards Radrails since it’s
based on Eclipse. The future of Radrails is especially promising as
they are planning to work in conjunction with the RDT
project where RDT will provide the core Ruby editing features and
TestUnit support, whereas, Radrails will provide the Rails specific
pieces such as editing RHTML, starting and stopping web servers, an
interface to script/generate, etc…

A really nice IDE is the
one thing I miss most when programming Ruby on Rails so here’s hoping
to the continued success of Radrails! Check it out if you’re looking
for a Ruby IDE, it’s still got a ways to go but it looks very
promising. They have a full installer (if you don’t have eclipse) that
incluces subclipse for subversion support which is a nice touch. If you’d rather watch than try they’ve also started creating videos.

Validation belongs in the domain model, not the MVC framework

Monday, December 5th, 2005

In the Java world validation almost always seems to happen in the MVC
framework. For example submitting a form causes some validation to
occur on the form and then if all checks out the domain objects are
populated and saved. I’ve never been crazy about this approach but
Hibernate doesn’t really address the validation issue and most of the
MVC frameworks do, so that’s often the easiest place to put it. The
problem is that most applications have numerous paths to load data
including web services, web pages, bulk data loading tools, etc… and
if your validation is all tied to your MVC framework you can’t easily
reuse it in the non-web paths.

Using Ruby on Rails has convinced me that putting your validation in
the domain model is generally the best approach. With Rails using
ActiveRecord that’s how it’s done and when the object fails to validate
those validation errors can be returned in a web form, data loading
tool, web service, etc… The validation is centralized and just
happens by default. As long as I get the validation right then I don’t
need to worry about another programmer writing a web service to
populate data and all of a sudden we have bad data in the database.

Here’s an example of one of my active record domain model classes with validation built in.

class Entry < ActiveRecord::Base

# Relationships
belongs_to :bliki

# Validation
validates_length_of :name, :within => 6..100
validates_uniqueness_of :name
validates_format_of :name, :with => /^\w+$/,
:message => “cannot contain whitespace”
validates_length_of :content, :minimum => 10
validates_associated :bliki
end

If you know of a good way to add validation to domain model objects in
Hibernate that gets called whenever a save or update is attempted
(perhaps via interceptor) I’d like to hear about it. I’d really like to
find an ActiveRecord style validation approach for Hibernate!

Cloaking, no need to be ashamed

Friday, December 2nd, 2005

Cloaking, the process of showing a user one view of your page and a
search engine crawler another view of your page is (I believe) a
fairly common practice that’s been hotly debated in the past and
discouraged by search engines.

In reality I’ve seen sites use cloaking to strip navigation elements,
hide form data, disable multi-page results, etc… to increase search
engine ranking while at the same time decreasing page size for crawlers
and decreasing the number of pages that need to be crawled. Given that
crawlers represent over a 3rd of page views for many high traffic sites,
cloaking has its economic advantages as well.

In my opinion there is nothing wrong with cloaking and it can be
used effectively as long as it’s not abused and the basic underlying
content and concept of a page stay the same. It’s a bad thing when used
to artificially increase keyword density or misrepresent the content of the
page to simply get page views.

I’ve always been a little hesitant to talk about effective cloaking
techniques with colleagues at other companies though. Cloaking
seems to be a dirty secret that most people feel they shouldn’t talk
about. Just observe how most people who work for a website that
economically depends on search engine traffic will publicly deny
cloaking.

Anyhow, I was surfing around with my user agent
set to GoogleBot to see which other sites are engaging in a little
cloakatude. Low and behold
Amazon behaves differently when you send it a user agent of Google Bot.
No search box in the top nav… makes sense… crawlers don’t use
forms anyhow, why spend money on bandwidth to serve them up a form
they’ll just ignore.

I found other major sites as well that were doing similar cloaking.
Not
bothering to serve ad code to known crawlers, removing unnecessary
content, etc… Anyhow it just goes to show that some degree of
cloaking seems to be happening at many major websites. I for one think
it’s fine. Why spend tens of thousands in bandwidth serving up extra
pages or content that’s not relevant to crawlers anyhow?