06 Jul, 2007

Published at 04:26AM

Tagged with asp, development, and programming

This post has 1 comment

ASP on Rails

I’ve been developing solely in Rails for several months now (a lot longer considering my own time), and I’ve become biased as to how web applications should be setup. And how’s that you ask? Exactly like Rails. If you’re subscribed to my web portfolio feed, you’ve probably already seen the most recent project I just added. You may also already know that it was built in ASP/VBScript.

Before Rails, the only other web development experience I have is in PHP and a little bit of C#/VB .NET crapola. So I don’t know a whole lot. The PMI project was to be built in regular ASP and VBScript, which was completely new to me. From the beginning, I knew I wanted to try and adopt some ideas brought forth by the Rails framework. I quickly realized how spoiled I’ve become (it took way too long just to get the DB and configuration stuff working). Trying to set my own conventions, I was able to do things like generate menus and sub-menus dynamically based on page location. Here are a few other things I tried in order to mimic a Rails environment:

  • included a separate helpers file that had various methods to ease my pain (which is better: response.write("message") or p("message")?)
  • mocked model classes by building CRUD operations in classes based on the DB table names
  • used one “layout” file that contained the header, footer, sidebar, menus, etc, while loading dynamic templates based on location (I have a gripe about how I had to do this, though)
  • convention over configuration

More about the gripe with my generic dynamic templates. This is where I was limited the most, as ASP doesn’t support dynamic includes! Instead of using a convention to fill in the file I needed based on page location (i.e. <!--#include virtual="/content/<%= get_page_name %>.asp"-->), I had to have a “content_for_layout” file that had about 20+ if/elseif conditions to determine which content to load. And it gets much worse. Even though only one of those includes are executed (the one inside the true if condition), all of them get loaded. I only needed one view at a time, but had to basically load every template within the site. Awful.

In the end it was kind of fun breaking away from Rails for a little while. Well, it wasn’t fun leaving Rails, it was fun learning something new, though. And on a side note, I can’t fathom how brilliant and consistent you have to be to extract out a framework such as Rails. It’s amazing. I’ll probably be releasing ASP on Rails under the GPLv3 license in the near future, so stay tuned (haha… not really).

Comments

helgi Wednesday, 15 Aug, 2007 Posted at 05:57AM

Actually I’ve done something similar in ASP3 with JScript. I based it on both the ASP.NET component model and Rails. Instead of using an include file for the templates I use Server.Execute to include a template, which in turn includes the required controller. I also created some handy shell scripts for creating a site as well as for creating (crud) controllers/views. However, instead of using ActiveRecord I use services. Basically it’s one service per table, but its easy to inject methods into different services if I require special lookup methods. Quite handy for generating reports.

Do you have something to say about this post?
Retype the image to the right Spam Hint: Are You Human? Textile Formatting Tips

or

Ryan Heath | Site Management A Ruby on Rails production.

This site is a Formed Function. Formed Function LLC | @formedfunction | Get in Touch