Making the old new: Classic ASP and CSFBL

It’s embarrassing to say that my longest project, CSFBL (a web-based multiplayer baseball game), still has most of its interface written in Classic ASP. It’s also embarrassing to say that the web interface for CSFBL is a bit 1990s. I’ve had a lot of false starts moving forward to new technologies, having experimented on moving to WebForms, Castle MonoRail, and ASP.Net MVC (twice). The “next big thing” for CSFBL has, sadly, become a bit of phantomware similar to Duke Nukem 3D.

The hard part of moving to a new technology is getting rid of technical debt. I started coding CSFBL in 1999, using classic ASP and SQL Server. It’s amazing to think that some code is still the same as it was 17 years ago, but that’s not surprising for a product that’s been around for, well, 17 years. But it is what it is, and moving to something new means breaking something old and reliable — even if old and reliable is a beat-up old car that still runs great but is not so pretty to look at.

Taking a hard step backwards, I had to take stock and decide what is truly holding me back, and realized that it’s not the technology that holds me back, it’s that technical debt. So I experimented for a few hours, and then realized that my platform — Classic ASP and SQL Server — is already solid. I just needed to clean it up and make it work.

Classic ASP is more powerful than people give it credit for. I’ve done a lot with it over the years, even to the point of building a mini-ORM to make coding easier and modular. The newer code I’ve written is clean and functional. So why not take it all the way?

First, here’s three screenshots of a typical CSFBL page. The one on the left is the current (“legacy”) version, the other two are the new (“modern”) versions, built with Twitter Bootstrap, showing the desktop and mobile versions of the same page (fully responsive design so one page works for all devices).

CSFBL (legacy) CSFBL (modern, desktop) CSFBL (modern, mobile)

 

What a difference design makes… but how do we make that work in Classic ASP in a clean way?

Here’s the basic ASP template:

<%@ Language=VBScript %>
<% Option Explicit %>
<!-- #INCLUDE VIRTUAL="scripts/cTemplate.asp" -->
<%
	Response.Write template.GetHtmlHeader("Template")
	Response.Write template.GetPageHeader()
%>
	<div class="container" id="container-main">
		<div class="row">
			<h3>Template</h3>
		</div>
	</div>
<%
	Response.Write template.GetHtmlFooter()
%>

That’s a nice clean template. And the bulk of the work is done in the cTemplate class. What is that, you ask? It’s a class that allows us to do things like GetHtmlHeader() and GetPageHeader(). Here’s a snippet. The “htmlheader.html” files is a plain HTML file, with some curly braced tags for inserting the page title and timestamp of the CSS file (so we can better handle browser caching).

class cTemplate
	private m_htmlheaderfile
	private m_cssfile

	private sub Class_Initialize()
		set m_htmlheaderfile = new cFile
		m_htmlheaderfile.Load( Server.MapPath("/scripts/htmlheader.html") )

		set m_cssfile = new cFile
		m_cssfile.Load( Server.MapPath("/css/csfbl.css") )
	end sub

	private sub Class_Terminate()
		set m_htmlheaderfile = nothing
		set m_cssfile = nothing
	end sub

	public function GetHtmlHeader(title)
		dim output
		output = m_htmlheaderfile.GetText
		output = Replace(output, "{title}", title)
		output = Replace(output, "{csstimestamp}", CDbl(m_cssFile.DateLastModified))
		GetHtmlHeader = output
	end function
end class

dim template
set template = new cTemplate

What about things like querystring handling, since the URL of this page is “/team/awards.asp?teamid=###”? Simple — just parse the querystring, and load the team, and if it fails, send the person to a friendly “not found” page.

Dim team
Set team = new cTeam
team.Load(utility.ParseInteger(Request.QueryString("teamid")))

If team.ID = 0 Then
	Server.Transfer "/notfound.asp"
End If

That “utility” is an instance of another class, with utilities to do similar things in repetitive ways, like parsing integers.

The point is this: classic ASP isn’t bad. Like any technology, it can be mis-used. But when used properly, there’s a lot that can be gained with a small amount of work — especially when moving from a legacy codebase to a clean codebase.

For a functional comparison of the two pages above — both working on the same Classic ASP/MSSQL platform, and both using the same SQL back-end — try the following two links. The only difference between the two is the HTML/CSS/JS rendered.

Legacy: http://www.csfbl.com/teamawards.asp?teamid=5
Modern: http://dev.csfbl.com/team/awards.asp?teamid=50

Podcast interview with the creator of CSFBL (me!)

Earlier this week I had the pleasure of being a part of my first podcast! ZubaZ, a long-time player and active community member of CSFBL (the multiplayer baseball game I’ve been running for over 15 years), interviewed me for the 25th episode of his podcast series, Threads of Time. We talked about the history of the game, revealed some of its secrets, and outlined some of the plans for the future.

It was a lot of fun — and inspiring. For a long time, I knew that the game was good and that the community was great — and this podcast just further reinforced those thoughts for me. I have to give a serious hat-tip to ZubaZ, who made it easy to talk for nearly two hours about something that I’ve spent countless hours of my life working on.

Thanks to ZubaZ, and the entire CSFBL community for giving the game the longevity it has.

Check out the podcast: Threads of Time Ep25 – Brian

Looking for advice on open source licenses

I’ve been developing (and operating) CSFBL, my multiplayer, web-based baseball game, for over eight years. After mulling for quite some time as to the future of the game, I’m seriously considering the transition of the game to an open source project. That being said, finding the right open source license is important.

After doing my reading, I’m thinking of going the route taken by MySQL – i.e., open-source under the GPL, but the potential for closed-source and commercial options available with a separate license.

Realistically, I highly doubt people would come to license the software for commercial use, but I do want to protect the product, intellectual property, and my sweat equity (I’ve spent an inordinate amount of time, money, and energy on it over 8+ years). My interest is in sharing it (and getting help from others), not letting others profit off it. (Hence I am avoiding licenses such as BSD).

Does anyone have suggestions, thoughts, or words of advice on this matter?

Baseball Mogul Online is shutting down — but CSFBL isn’t, so why not check it out?

I just stumbled upon this announcement from the Baseball Mogul Online forums:

This page is to notify all Baseball Mogul Online users that we will be discontinuing the service as of December 1, 2008.

Why?
There are three main reasons:
#1 -The system is not profitable to operate for us. Even when it was at its peak of usership, it did not bring in enough money to support further growth and improvements.
#2 – We no longer have the staff needed to operate the system.
#3 – The machines and bandwidth that the system runs on were designed for a much larger load than we currently use. To economize, we will be switching services and bandwidth, and the new equipment will not support Mogul Online.

Sincerely,
Dee and Clay Dreslough
Sports Mogul Inc.

Well how about that. I’m as sorry as anyone to see a solid game go away, but there’s good news to all Baseball Mogul Online fans — there’s an alternative that is not going away, and it’s 100% free: CSFBL!

CSFBL, the Computer Simulated Fantasy Baseball League, the grand-daddy of all multiplayer baseball management simulations, is still going strong. In fact, we’re probably stronger today than we’ve ever been.

Even better, there is no reason to fear that CSFBL will go the path of Baseball Mogul Online. Why?

  1. Profitability doesn’t matter. The game is funded out of my pocket and with the help of generous donations from our members. We don’t have to make a profit to keep running. (In fact, we’ve almost never made a profit, but the game has kept running — for over eight years — despite that fact.)
  2. Our staff is volunteer, so they’re easy to replace. Everyone who helps out with CSFBL does it of their own free will, because they love the game and the adventure in helping watch it grow. Much like open source software projects succeed despite any paid staff, CSFBL has succeeded and will continue to succeed under the same model.
  3. We’ve got horsepower to run the game. About six months ago we upgraded to a new server. With all the kinks worked out, we’re now running faster and more reliably than we have in years. Even better, we’re about to migrate our forums to vBulletin as we move to improve our community features. On top of all that, if we generate revenue above our expenses, my intent is to continue to expand our infrastructure to keep up with growth and demand.

Don’t get me wrong, CSFBL has had its share of growing pains — but what you get, for the price you pay, is simply incredible. Aside from a feature-rich game (running on a baseball simulation engine that has been battle-tested for over eight years) and a rich community, there’s also one thing that is rare in any online service, much less a free one: The guy who runs it is honest, up-front, and always involved.

Why not check us out? http://www.csfbl.com

CSFBL find a new home

Nearly four years ago, on September 16, 2004, CSFBL – the Computer Simulated Fantasy Baseball League (the greatest web-based multiplayer baseball simulation ever made, in my opinion, despite the long name) was migrated to what was (at the time) a hot new server. Performance was spectacular, and things stayed rather well… for a while…

Fast forward to 2008. CSFBL was crumbling under its own weight — and popularity. A game that was originally designed to handle a few hundred users now had thousands. More users meant more teams; more teams meant more games simulated; more games simulated meant more server utilization… The 3+ year old server, once handling the every-three-hour simulation in an hour and a half, took four or more hours to get it done. People were frustrated; I was frustrated. Something had to change.

Continue reading