Posts tagged with subsonic

Recent activities and inactivities

It has been a crazy couple of months between moving home, spending a week in Seattle and a couple of days in Holland for my real day job (the source of income!)

It was a little too close to my USA trip which has meant I’ve missed my niece trick-or-treating for the first time since I returned to Guernsey 3 years ago which leaves me a little sad. I guess I should be grateful for not being hit with jet-lag and the fact I’m surviving just fine on 5.5 hours of sleep a day which tonight is in a cubicle hotel…

As you can imagine the fun projects I get involved with in my own time have suffered somewhat although I’ve really tried to at least keep the blog posts flowing. Here’s a quick update on things:


I’ve committed the final piece of my refactoring to make the coding languages abstracted. To add additional programming language support you can now just implement the ICodeLanguage interface and add knowledge of it to the CodeLanguageFactory class. The command line and web interface tools will all just magically work with a recompilation.

Rob Conery is now under the employ of Microsoft and will be aligning SubSonic with their MVC efforts. I hope this support of open-source projects is a trend Microsoft are keen to continue.


This great add-in for Visual Studio provides Subversion integration continues to face competition from the commercial VisualSVN front and I had an interesting discussion with Aaron Jensen about performance with large projects and some relating to moving.

I have some UI work checked-in to trunk and we are likely to move to a better model for integrating with the Solution Explorer to address these issues that would require we drop Visual Studio 2003 support which is looking quite likely. Various things are moving forward on this project so keep an eye on it!

Envy Code R

I’ve not touched Envy Code R since the PR6.1 release but to be honest this tends to be the way I work with it. Nothing for weeks then 15 hours over a weekend gets it to the next release. Unlike code I find it difficult to jump in and out whilst being productive and consistent. Perhaps when I’ve worked on a bunch I’ll be able to but this is still my first scalable font.

The plan is to add all the essential box-drawing characters for code page 850, extend the # sign (should we slant this in the non-italic version?), increase the curves on { and } and adjust the comma to make it less like a slightly deformed dot. I’m open to suggestions as to whether the .,;: characters should in fact revert back to be square dots rather than round ones… again, leave comments if you have an opinion. I’m not sure whether I would extend this squaring back to the dots on ij! etc.

I’m hoping to get preview 7 out within the next couple of weeks and if that goes well then consider a more liberal license to allow bundling etc. as I’ve had a couple of enquiries.

Silk Companion icons #1

Preview of some icons in Silk Companion #1My pack of addition Silk style icons has suffered as I find it impossible to draw on the move requiring instead a comfortable desk and a proper mouse to draw. As I no longer have a desk at home this means staying late in the office or throwing my lunchtimes at them.

The temptation is to just release the 352 icons as they currently are and produce another set at a later date. The alternative would mean a release some times over the next 1-3 weeks when the number finally reaches the proposed 500 mark.

If you have any thoughts or suggestions, leave a comment!


Rails-style controllers for ASP.NET

Rob Conery has been putting together some great screen casts on SubSonic and his latest on generating controllers pointed out that ASP.NET doesn’t support the Rails-style http://site//controller/method style of execution.

This got me quite excited and I’ve put together a proof-of-concept web project that demonstrates mapping the path to controller methods using an IHttpHandler and reflection.

How it works

It registers the ControllerHttpHandler via the web.config:

  <add path="/ctl/\*/\*" verb="POST,GET,HEAD" type="ControllerHttpHandler" />

There is a very basic Controller abstract base class that just provides a simple way of accessing the context for dealing with request/response for now.

public abstract class Controller
  protected System.Web.HttpContext context;

  internal Controller(System.Web.HttpContext context) {
    this.context = context;

We then have a test controller or two that implement from this with a couple of methods and the required constructor:

public class TestController : Controller
  public TestController(System.Web.HttpContext context) : base(context) { }

  public void Index() {
    context.Response.Write("This is the index");

  public void Welcome() {
    context.Response.Write("Welcome to the TestController");

Finally the magic that joins them up is the ControllerHttpHandler:

using System;
using System.Web;
using System.Reflection;

public class ControllerHttpHandler : IHttpHandler
  public void ProcessRequest(HttpContext context) {
    string[] parts = context.Request.Path.Split('/');
    if (parts.Length < 4) {
      context.Response.Write("No controller & member specified");

    string controllerName = parts[2];
    string methodName = parts[3];
    Type potentialController = Type.GetType(controllerName);
    if (potentialController != null && potentialController.IsClass && potentialController.IsSubclassOf(typeof(Controller))) {
      MethodInfo potentialMethod = potentialController.GetMethod(methodName);
      if (potentialMethod != null) {
        Controller controller = (Controller) Activator.CreateInstance(potentialController, context);
        potentialMethod.Invoke(controller, null);
        context.Response.Write(String.Format("Method '{0}' not found on controller '{1}'", methodName, controllerName));
      context.Response.Write(String.Format("Controller '{0}' not found", controllerName));

  public bool IsReusable {
    get { return false; }

That’s it!


The controllers and methods are mapped at run-time using reflection. This would probably be too slow for production. Also it currently has to be in a top-level folder because I can’t figure out how to pass the HTTP request back to ASP.NET to try with the rest of the stack if we don’t have a matching controller/method.

One option might be to have no httpHandlers in the web.config and add the exact controller/method maps at build or run-time. This solves both the top-level problem and potentially the speed.

Another option to address just the speed of reflection would be to cache the path/method strings to the actual method and type so the only reflection would be the Activator.CreateInstance. If that is slow then we could look at pooling the controller instances themselves.

Going forward

Parameters for a method could be extracted and parsed from the query-string – they are currently ignored.

Response is raw output – we could do something very similar to rhtml.

I’m going to chat things over with the Subsonic team and see if we can come up with anything from here.


What are you doing for the next 6 months to be a better developer?

Scott Hanselman posed the open question on his Hanselminutes podcast and there have already been some good responses. My own plan includes:

Improve programming techniques

My girlfriend gave me the well-regarded Code Complete, Second Editionfor my birthday. I shall read it cover to cover and adopt good practices I am not currently practicing.

Manage my life

I have started reading GrinGod’s copy of Getting Things Done: The Art of Stress-Free Productivity. I will move tasks out of my head and concentrate on what is achievable right now.

I have set-up these tasks now in Midnight Inbox (great but a little rough) and will keep an eye on OmniFocus. I will be prepared to use my free Moleskine I won in the Moleskinerie summer draw if neither does the job and not immediately write my own software.

Interact with other developers

My Subversion talk at the Guernsey Software Developers Forum went well. I will seek new members and engage in discussions of development with regards to local issues such as those in the finance industry.

I will spend less time on IRC as it is distracting and the non-persistent nature means good answers are lost. Instead I will help more on forums and be prepared to wait for answers to my own questions.

Learn new technologies

I will investigate technologies and learn them where they appear applicable to my work or I find personally interesting. These include:

  • Ruby on Rails – clean MVC development with AJAX support… but what about libraries and performance?
  • LINQ – simple but powerful object-relational mapping as standard but far away in .NET 3.5
  • Cocoa – Apple’s OS X development based around Objective-C giving compilation and dynamic typing
  • MonoRail – if I’m going to continue with ASP.NET it won’t be with WebForms
  • SharpDevelop – the Visual Studio API is terrible and this project looks well designed and usable

Contribute more to open source

I will contribute more to my favorite open source projects. This includes:

  • AnkhSVN – improve user interface and head up the 1.1 release
  • SubSonic – refactor more code and help out where I can

Lead development at work

At my new job I will concentrate on the new technology and vision for the next-generation of tools to deliver to our staff and customers and lead my team as appropriate.

I will distill my experience contracting for the last 7 years into the best practices for the company and continue to lead them in adopting modern practices. We now have have source control, formalized request for change and release management procedures however we still need to embrace new tools, write comprehensive unit tests and switch to object-relational mapping for new development.

Switch key-map to Dvorak

I have swapped out my DAS 2 at work for my Apple Pro with the key caps rearranged for Dvorak. I will stick to this layout until I can properly touch-type. I won’t actually make me a better developer but it should keep RSI at bay. (This post was written using Dvorak)


What I’m up to at the moment

The project I’ve been working on professionally for the last two years reaches a milestone this week and so is a great opportunity to take a well-deserved break for a couple of weeks.

I was hoping to head out somewhere as far out as Japan but things are held up in a complicated set of scheduling dependencies and a looming demo to investors.

At home I’m currently working my way through Microsoft .NET Framework 2.0 Windows-Based Client Development Training Kit (nice name there Microsoft) as part of my studies towards exam 70-526. This is a requirement to obtain a Microsoft Certified Professional Developer (Windows Applications) which I’m hoping to add to my resume.

The initial test they provide on the CD-ROM wasn’t too tricky however some of the questions seem rather obscure and irrelevant. This is apparently quite normal for Microsoft exams and does seem to be a little familiar when I think back to my Internet Information Services 4.0 examination I took in 1999 to get my Microsoft Certified Professional certification.

I’m also finishing off a few additional icons for AnkhSVN particularly in the area of the Working Copy Explorer and the Repository Explorer dialogs. Once I can get the Subversion 1.4/APR/zlib dependency libraries etc. installed again then I’ll be able to test and commit those back. I’ll bug Arild to put the 1.4 dependencies up on Tigris for other people wanting to hack around with the source too.

GrinGod and myself have been considering writing a small blogging system in .NET using the SubSonic ORM. I’ve been tempted for a while and today Phil Haack, maintainer of Subtext, dropped the clues that he’s also wanting to switch Subtext to an ORM although would like to do it very slowly.

I, on the other hand, am quite keen for a very lightweight free .NET based ORM that doesn’t provide UI based configuration or skinning abilities instead relying on the developer to get his hands dirty for customization. More of a .NET blogging system for .NET developers who want to integrate it with whatever they’ve rolled for their site.

And it seems we can borrow all sorts of stuff from the Subtext source tree.