September, 2004

Sep 04

Trails on your doorstep

I miss having trails on my doorstep. When I stayed in Haddington I could leave the garden and be off-road in about two minutes and when I’d been out for a couple of hours I could freewheel back down to my house and jump in the shower. Granted, it’s not the best mountain biking ever, but it is very quiet and there are a few wee gems scattered around. My friends and I didn’t take it for granted when we were growing up and realised exactly how lucky we were. I’m not saying that where I am just now is terrible or anything like that, after all I can cycle to the Pentlands in half an hour or jump in the car for the same sort of time and get somewhere equally good. I guess what I really miss is the chance to just stick my kit on and go with no notice and no hassle.

If I fancied just getting out for and hour, that’s exactly what I’d do. No fannying about carry bikes down stairs (top floor flat) and getting stuff in the car, just chuck on some shorts and go for a spin. If the weather was nice and I just wanted to be outside I could take a walk or a ride up to the top of the hill and just sit there enjoying being alone in the fields and absorbing the wicked views. Sometimes we’d head out for a blast before school and there always seemed to be plenty time to ride in the evening too. It was great.

So, that’s another thing to factor in to the ultimate place to live – mountain biking straight from your door. Unfortunately the list of wants in a place to live is growing unfeasibily large, so something’s got to give, but I think this is one that’s especially important to me.

Sep 04

MVC for web application architecture with PHP

Warning: techy post alert, but if you’ve got past the title, you might just be interested. I’m just experimenting with MVC in a web environment at the moment, so please don’t take anything I’ve written here as gospel. I’ve written this mostly because it could be interesting to read it again in six months – “What was I was doing that for?”. There are several good sites to read about this stuff if you’re interested, although the nature of it means that it’s all open to interpretation and modification.

I’ve been messing around with MVC as a framework for SC3 recently. Mostly I’ve just been trying out ideas and getting a feel for how things work to see if I want to use MVC at all. Because it was the first site I had developed with any sort of database interaction, ScottishClimbs currently runs almost completely on procedural code. Recently however, I have been frustrated by looking at the spaghetti mess of code that was left over from SC2. At university I did a lot of work with Java, and have a decent understanding of object-oriented programming, so it made sense to start looking at object-oriented frameworks for the development of the new site.

I already knew a bit about developing applications with MVC and have recently done a lot of reading about converting that to web applications. MVC is a great way of separating business logic from presentation logic and data logic, and this is the aspect of MVC that I really like. However, it has some features that seem awkward for web development. In order to stick to the MVC model a lot of people are having a single controller (FrontController) and limiting access to the entire site to one page (usually index.php). The controller then takes various $_GET parameters and determines what view (page) to display. I daresay a single entry point for the app has some advantages, but for me it seems to lack flexibility and certainly complicates the code. The alternative is to simply structure the site into pages as normal (index.php, viewpost.php…) and have a controller per page (PageController).

Once I’d implemented a couple of pages though, it was apparent that the PageControllers were doing little more than running some procedural code, so I scrapped them and moved the code to the page itself, which simplified things again. I think object-oriented programming is great, but I’m not sold on the idea that we need to make everything into objects just for the sake of it.

At the moment I’m at the stage where I’ve implemented a few pages, all of which access data only, but the trickyness and ambiguity of MVC is starting to show. Plenty of ‘Where does this belong?’ type of thoughts are floating around my head. I’m not sure the situation is helped by the structure of the new SC3 site – by it’s very nature accessing the data almost always involves multiple joined tables (how should models be separated: by table? Some sort of logical grouping?) and often displaying the data involves a call to fairly nasty XHTML generation function of some sort (that I wrote last year, thankfully!).

Currently I’m using several models equating to my logical grouping of the site data, the actual page as the controller and one view per page. Some of the models, like the PostModel – used for getting, wait for it… data about posts – have an associated helper class. This class simply provides a set of functions, used by more than one view, for helping to display the data – like generating a list of areas and categories nested in a list of posts. A view builds a page by creating a template object, calling on a helper (if necessary) and setting some variables in a multi-dimesional array (currently $content, $sidepanel, $title and $heading). When the view is rendered by the page it simply displays the XHTML file associated with the template and fills in the variables. I’m really happy with the way the XHTML is isolated from the rest of the application like this and I think the template system I’m using is simple and elegant.

MVC was designed so that the presentation, data and business logic could be easily separated and it does a great job of this. However, it’s not entirely clear what should go where sometimes, and other times things just don’t make sense when fitted into MVC. The model and view certainly make quite a lot of sense to me, the controller just doesn’t fit as nicely. The major drawback for me is the added complexity – there are a lot of different classes floating about – and this is an area that I really want to see if I can improve in my MVSomething system. MVC isn’t the perfect architecture for web development but, so far, I’ve not seen anything better and I think I’ll continue to use some form of it with my development work in PHP.

Sep 04

The Unusual Suspects Vol I

Dave has released the first half of his fictional Scottish climbing tale, The Unusual Suspects. It’s a bit of a fantasty epic involving bouldering, murder and deceit (and a fair amount of that Redpath style :)) amongst some of the characters of the Scottish scene in the boulder strewn Corie Lagan.

Vol II will be coming to your favourite Scottish climbing website next month.

Top effort Dave.

Sep 04

The KLL avengers

Stuart, Marion (cool Aussie lass who’s in Edinburgh for a while) and I headed up to Kinlochleven yesterday to complete the loop Stuart and I tried last time, armed this time with a bit more knowledge. The weather was kind to us and I thought it was a really good day out.

We started, very briefly, on the West Highland Way, then turned right on the road to Mamore Lodge which soon turned into a fireroad climb to Loch Eilde Mor. Some of the trails around Mamore Lodge look pretty good, but we didn’t have a chance to explore them. Just before the loch we turned south onto some superb technical singletrack, heading for the Blackwater resevoir. As the path steepened there was a carrying section, but it was over pretty quickly and the track continued to be very good until we took a right turn (with hindsight, probably a mistake) towards the dam. The right hand path soon vanished and we were on an oh-so-familiar bog, pushing, swearing, falling and even (in one case) sqealing our way to the dam. Stuart and I had failed to find the path when we were heading in the other direction and I now seriously doubt whether it exists in any decent form at all. If anyone knows otherwise, please let me know. After an annoyingly long time for such a short distance we reached the dam.

Stuart and Marion didn’t fancy the technical path to Kinlochleven after battling the bog so headed down the West Highland Way, but there was no danger I was ever wanting a reason to go near that bog again, so it was up to me to engage in some concentration warfare on the rocky trail. It was, as I remembered, very rocky and I had to get off the bike a fair bit to carry streams and bits that were just a bit too mad. The bottom half is better than the top, which perhaps suffers from being just a bit too rocky and really forced me to ride slowly. Once into the bottom section however, things got really nice – there were still plenty of techincal sections but they were spaced out a bit more and I could get a decent flow going on the trail.

I don’t think I’ll be rushing up there to do it again (too many other things to do!), but as far as technical trails go it’s a bit of a must-do in my opinion. 7 out of 10 Mark Points for the route – it loses 1.5 points for the boggy section.

Sep 04

Me and the future of kiteATB

How I see the/my future of kiteATB.