Tag archive for 'subsonic'

31
Oct

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:

SubSonic

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.

AnkhSVN

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 licence 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!

[)amien

26
Jul

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 a IHttpHandler and reflection.

How it works

It registers the ControllerHttpHandler via the web.config:

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

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");
            return;
        }

        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);
            }
            else
                context.Response.Write(String.Format("Method '{0}' not found on controller '{1}'", methodName, controllerName));
        }
        else
            context.Response.Write(String.Format("Controller '{0}' not found", controllerName));
    }

    public bool IsReusable {
        get { return false; }
    }
}

That's it!

Limitations

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 runtime. 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.

[)amien

19
Jul

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 Edition for my birthday. I shall read it cover to cover and adopt good practices I am not currently practising.

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 favourite 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 distil 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, formalised 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 keymap 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)

[)amien

14
Nov

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 customisation. 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.

[)amien

09
Nov

My development tools

Christopher Bennage wrote about his development tool set-up and encouraged others to do the same so here's my current set-up.

Daily tools

  • Visual Studio 2005 - IDE of preference despite it's sluggish behaviour
  • SQL Server 2005 Management Studio - Took getting used to but it's an improvement on 2000's Enterprise Manager
  • AnkhSVN - Subversion support inside Visual Studio 2005
  • .NET Reflector - Searching .NET API or to find out what it's doing
  • Web Application Projects - Stop using VS's web sites and start using web applications!
  • Web Deployment Projects - Deploy to dev, test or live servers as easily as building a project

Not quite daily

  • CodeSmith - Need to get to grips with v4 to build our whole database layer in one hit
  • Trac - Bug tracking, milestones & wiki with integrated support for Subversion
  • TortoiseSVN - Check-in/out of non-project items (e.g. art assets)
  • Web Developer Extension - Trying CSS changes on-the-fly, validating pages etc. from Firefox
  • Firebug - Examining pages, the page DOM etc. from Firefox
  • KDiff - Excellent 3-way diff tool that works great with AnkhSVN
  • Subtext - Blogging system running here

On occasion

  • Visual C# Express and XNA - Messing with 3D graphics, controllers and pixel shaders
  • Ogre - Steve's object-oriented 3D engine
  • XCode and Cocoa - Still quite alien with it's message-based calling mechanism but obviously powerful

Keeping an eye on

  • Eclipse - IDE for developing Java (C++ and C# support in various stages too)
  • Ruby on Rails - Interesting RAD approach to web development - Apple also supporting on Mac OS X 10.5
  • Sandcastle - Microsoft's documentation tool that already seems to have had an impact on NDoc
  • SubSonic - Build-provider that generates an ORM on the fly and provides automatic developer-only db editing pages

Not used lately, still installed

  • Delphi 5/6 - Borland's great RAD tool for non-.NET development, later versions support .NET too
  • JBuilder - Java development although I'd probably move to Eclipse
  • Visual Studio 2003 - Still required for the odd .NET 1.1 application/testing

[)amien

04
Oct

App-A-Day & SubSonic

Screenshot of WPM Tray in action

App-A-Day

Self-proclaimed Code Jedi Dana Hanna is on a mission to destroy his personal life by writing an application every day for 30 days.

There are a few great apps in there and all come with source - the ones I checked out were in C# :)

Some of my favourites are:

  • WPM Tray - display you word per minute count graph. Also a demonstration of how to hook global key-presses in C#
  • Jedi IRC - a small IRC application as a Visual Studio plug-in - both interesting things to see done in C#
  • Mouse Heat Map - get a display of where your mouse lives on your desktop! :D

I must confess these tiny fun apps have inspired a couple of my own that I'll hopefully knock up and post at some point.

SubSonic - The Zero Code DAL

In other news SubSonic has come on a lot having addressed all the major issues apart from still being ActiveRecord based over DataMapper pattern. (If you haven't seen it before check out the 20 minute screencast)

Rob, the brains behind SubSonic, has been interviewed over at the DotNetRocks podcast and I recommend giving this one a go - don't let the first 5-10 minutes of warm-up and ads put you off.

He's also put together a starter site solution you can pick-up from the same place which has some useful bits.

[)amien

29
Aug

Choose your ORM: Runtime, code generation or build provider?

Selecting the right object-relational mapper is a tricky decision with many factors to weigh up.

One of the basic decisions is whether to go with a dynamic runtime ("black-box") or a code generator.

I'm not a fan of the runtime approach - the discovery at runtime negatively impacts performance as it often uses reflection (or failing that post-compilation byte code modification) whilst robbing you of compile-time checking, IntelliPrompt support against your database objects, deployment and potentially licensing issues. In effect, it's not that much better than a typed dataset.

Code generation provides for a much finer granularity letting you tweak the templates for the performance and features you need whilst also providing full compile-time checking and IntelliPrompt support.

Tools such as CodeSmith (my personal favourite), MyGeneration (free) do a good job of letting you write these templates and create the necessary ORM code but require being re-run every time you change the schema. During the starting phases of a project this could be quite often and goes against the whole concept of RAD.

So step in SubSonic and it's build provider approach.

The idea here is that you modify your .config file to include the SubSonic build provider and it's connection string, drop a simple text file in that lists which tables to work with and you're done.

SubSonic now goes off to your database via the connection and generates all the code for tables you need and it's magically there to be used like any other classes. Check out the demo to see just how easy it is.

SubSonic supports a large number of databases, has support for Enterprise Library, is open source and also provides simple "scaffold" pages that let you throw a basic web add/edit/update/delete table maintenance page by just throwing a table name attribute onto an empty page's form element.

The only downside at this point is that it uses the ActiveRecord pattern for the ORM. If I manage to get some time to spend with it and can knock up a Domain Object + Data Mapper version I'll let you know.

[)amien




Topics