Gonzo blogging from the Annie Leibovitz of the software development world.

Day: February 10, 2004

Lots of updates… elsewhere

Don Hopkins website came back (as was expected, it seems to go stealth from time to time) and there’s a whack of updates. Thought I would point you to them as I don’t have anything from my own brain today.

He has a neat piece on Sim City for Linux. I talked to him a year or two ago and he had ported the app over to Linux (adding scripting capabilities through a language called TCL) and was going to motion to EA to allow him to distribute it for educational purposes. It’s apparently still lost in EA legal land (as does where most things seem to end up) so not sure if that will ever become a reality.

He’s got a posting on a nice proposal he wrote back in 2000 about building a common authoring SDK for The Sims. The next release of SimExplorer will have something like this in it although I’m not sure how far it will go and initially it won’t be documented (barely have time to write the app let alone the documentation for it) however the SDK thing has been a long time passion for me to get more people writing tools for The Sims.

A section about object hacking pointed me out to Slice City which is essentially Sim City inside the Sims. Quite an amazing feat of hacking by cobbling objects together and making them stand on their head and spin. As you may recall, I created an add-on object a couple of years ago that essentially turned all players into zombies (and creating a few NPCs on the fly), loaded the player up with a shotgun and locked all doors to the building they were in. This created a mini-resident evil game inside The Sims (to activate it you picked up a gamebox and selected an option from the pie menu). The exercise was a disaster as it really dug into the innards of the ways objects worked and I probably did a million things I shouldn’t have. In the end, it was a unusable attempt at object hacking and would lock up my system hard. Not a good example coming from the guy who claims he knows a lot, but then I think I might have been pushing the Sims envelope a little too much back then.

Refactoring in the .NET world

Refactoring is a fancy way of saying “optimizing your codebase”, but it’s a little more than that. Refactoring is a controlled technique for improving the design of an existing code base. It’s the process of taking an object design (in source code) and rearranging it in various ways to make the design more flexible and/or reusable. There are several reasons you might want to do this, efficiency and maintainability being probably the most important.

There are a series of “refactorings” that have generally been accepted as “common”. Martin Fowler is one of the father of these practices and contributed to create a catalog of them here.

Generally from a Software Configuration Management (SCM) perspective, it poses a challenge because when do perform a refactoring you end up touching potentially every file in the system but you can’t be certain which ones upfront. For example, let’s say I’m going to rename a method in a class (from getinvcdtlmt which doesn’t make much sense to getInvoicableCreditLimit). To do this, I could do a global search and replace (if my IDE had that capability) or manually change all the references to it. This means I hit every mention of this method in all my source. What if my source code was referring to this in multiple ways like through a pointer or something? A global search and replace might not work.

Bring on the tools. There are several tools on the market (mostly in the Java space) that perform these refactorings for you with a simple click of a button. In the example above, a global search and replace might be effective enough but for other refactorings (like splitting out a class into multiple classes) you need a tool that understands how code works, not text (or you end up doing this manually).

.NET proves to be an even more discreet platform for refactoring. There are a few tools out there but they’re either very early in development, difficult to use, don’t integrate very well with the Visual Studio .NET IDE, or just plain don’t work. Here are a few of the .NET tools I’ve found out there:


C# Refactory

C# Refactoring Tool

As time goes on I’m sure something will come out of this. The next version of Visual Studio .NET (Whidbey) will offer up the common patterns of refactoring, but that’s a year or so off. Lord knows I would love to come up with a definitive tool to do this, but given my current workload of projects (which I’m still trying to catch up with) I can’t rise to the task.

Anyways, if you’re interested in learning more about refactoring here are some links: