Blog asp.net

Avatar

Byron source code on Subversion

The source code for Byron, the heavily under-development content management framework for ASP.NET is now available through my Subversion repository.

Subversion is a system that allows developers to work collaboratively on applications, because it puts all of the source code in one place. You can also let guest users download the code, and it makes versioning easier and ultimately gives multiple developers more control over their projects.

As I’m the only developer I’m mainly using Subversion as a way of allowing others to see my work. Other sites exist for .NET developers (like CodePlex, Microsoft’s answer to SourceForge) but they often lack the automatic element that allows you to push your changes back to the server quickly. (I use Microsoft Visual Studio 2008 with a plugin called AnkhSVN that provides a fully integrated interface to Subversion.)

Byron is now being used for the Rhubarb Radio Website to power both the text content and the schedule, and in time (once I’ve made a few more tweaks and started writing the documentation and improving the code commenting [ie: adding some]) the framework will have its own site.

Anyway, should you fancy taking a look, you can find the source code for the libraries that are included in a Byron Website at svn.bluemilkshake.co.uk/byron/. Once the system gets its first major version number a test site will be included in the repository, so you can see how a site uses these libraries.

When best practises collide

Best practises are methods and techniques for achieving a certain goal. By their very nature they set the standard for us to follow, and form a mechanism by which developers can be judged.

ASP.NET is my platform of choice when developing applications, but it gets a bum rap from developers on both sides of the open source debate, for its creators’ inherently arrogant approach to Web standards.

While working on a new project I thought I’d have to bite my tongue when I saw some of the .NET markup that was being used, but after a while it dawned on me that what was being written wasn’t incorrect, it was simply following Microsoft’s best practises rather than, for example the W3C.

Under ASP.NET, the tools that allow developers to change the styling for Webpage elements (font faces, sizes, colours, etc) are very close to hand. When adding a text box control to a form, the user can specify its border style, font size and colour aswell as the usual stuff like maximum length and validation functionality. Now as part of the XHTML and CSS methodology, which encourages the separation of content and styling, this type of customisation is abhorrent: it’s simply not the done thing. However, when developing the .NET Framework (and specifically ASP.NET), Microsoft were simply following a pattern.

Some people actually don’t realise, but the .NET Framework in and of itself has nothing to do with Web development: it is simply a software framework. Programmers can build desktop and console applications, libraries and games with it. Now in desktop application development it is very common for developers to be given the option to change how a form looks by hard-coding the window styles directly into the application. There is no CSS technology for desktop applications, and so programmers pick colours from a specific palette (which include system colours) and fonts from a dropdown list, to suit their needs.

Not only can you build both desktop and Web applications with the .NET Framework, you can also use the same software (Visual Studio) to build both types of application, so developers could make the transition from building Windows Forms apps to producing Websites. Microsoft even took care to give the Web versions of their controls (like textboxes and labels) the same or similar name as their Windows Forms counterparts, with the same abilities to change styling that programmers had grown used to.

So I think it’s unfair to rail at Microsoft for not embracing W3C, when this isn’t actually the case. As a standards-conscious developer I’m not forced to use the hard-coded styling method that I would use with Windows apps: I can apply CSS classes to my controls just like I could in HTML.

So hard-coding your “look and feel” doesn’t make you a bad Web developer: just one that’s following one set of practises. Problems only arise when developers pick and choose elements from different methodologies to create their own which makes picking up someone else’s project that bit more difficult.

This realisation has made me a more forgiving programmer: now I just have to learn to resist the urge to force my ideals onto others.

Byron, deadlines and pulling an all-nighter

It’s been a long time coming, but finally Bluemilkshake has a .NET site again, after popping over to WordPress for a wee while.

WordPress is a great system, and one of the things I loved about it was the way you could just “get on” with writing without really having to worry about anything else, and that’s part of what I’ve tried to achieve with Byron, the content management system that this site is built on.

I moved hosting a week or so ago, from a budget PHP host to Fasthosts, and with the move came the necessity to close down the original site, moving as I was from PHP to .NET (in short meaning that the old site wouldn’t work).

So I put up a holding page claiming boldly that the new site would be up by July 1st, a deadline which had already been put back a few days. I had a number of other projects on at the time which needed my attention so inevitably my own site suffered, leading to something of an all-nighter, the evidence of which you can see in the three videos below.

10pm

12am

3am

There’s nothing like sticking to a good deadline is there!?

Anyway...there’s still a lot more to do on the site, and a lot of content to add but I felt it important to at least have a place I could direct people to, plus it’s nice to get my blog back again!

(I’ll be working on getting all the old URLs to redirect but in the meantime the RSS feed URL that readers use to subscribe is being automatically redirected so you should be able to pick this new post up in your RSS reader.)

Byron’s first stumbling block

On Thursday I started work on my new content management system for ASP.NET, called Byron. I wanted to make it both flexible and efficient and in doing so I’ve had my first setback, and it’s all to do with data.

ASP.NET has a great model for creating flexible applications that can be configured very easily and without having to write too much unnecessary code. The Provider module means that you can put all the logic for a set of functionality in one place, and worry about the nuts and bolts later.

For example, I started off with a DataProvider system. I created a base class with a load of functions for accessing information about users and their roles, so that I could build a login system for the admin area later down the road. I then built a MySqlDataProvider which inherited from the DataProvider class and which would actually handle the instructions that the DataProvider was being given.

So basically the user system says “reset this user’s password” and the DataProvider says ”OK. Oi, MySQL? Check this user’s password would you?” MySQL comes along, resets the user’s password and tells the user system it has done so. (A very simplistic description, but hopefully it makes sense.) That all works great because the MySqlDataProvider knows what data to access, in what table and what to do with it. Now comes the tricky part.

I want the system to be a framework or platform, more than a CMS. I want Byron to form the basis of all .NET sites I develop in the future, so that means the system needs to be flexible enough to deal with any type of content, be it a page, a blog post, a contact form or a news article. Because there are subtle differences between examples 1, 2 and 4, a catch-all system wouldn’t work, so total flexibility was what was needed.

So I built a ContentProvider and setup a whole load of stuff in the site’s configuration file so that new types of content could be created, understood and rendered. It all went swimmingly until I came to the point at which I’d have to access data for each page, post or article.

And that’s where the stumbling block came and whacked me square in the noggin. How do you access data from a database without knowing

  1. what the content will be used for, and crucially
  2. what form that data is held in?

It could conceivably be XML, a MySQL or MS SQL database or even - heaven forfend - a bunch of text files. If I wanted the system to be totally flexible it would have to cope with all of these, and more. And that’s actually OK as long as you know what data you need, but because the content system was dynamic too, I didn’t.

I knew that if I really knuckled down I could create a really fancy generic query system where the complexity of each query could be communicated and passed from the ContentProvider to the DataProvider and back again. But this would end up slowing the system down, and I’d have a foot-long white beard by the time I’d finished. So I had to make a compromise, and from now on, Byron will only support a MySQL database.

I wanted to allow the support of any database that can interpret SQL (a “programming” language for databases), but there are limitations which I won’t go into, so it’s MySQL or no SQL. Hey, if it’s good enough for WordPress it’s good enough for me!

Say hello to Byron

A few conversations, be they online or offline have lead me to think about whether I should be demonstrating my .NET skills through my own CMS. My priorities have shifted since I setup this site on WordPress, and now I think demonstration is more important than procrastinating.

My mate Kevin is already using version 2.0 of Bluemilkshake.ContentManagement on his site DigiKev, but it doesn’t give him everything a blogger needs. Yes he gets the basics: he can add new posts, add links, images, metadata and so on. But it doesn’t ping any servers when he updates his blog, and it doesn’t notify any posts to which he has linked.

Plus the system is not necessarily the most efficient. It was built on a module basis (a little like WordPress widgets, except those widgets don’t have to be stuck in a sidebar: they actually form the makeup of each post), so each block of text is one module, and an accompanying image is another.

It’s because of the issue above that I thought, rather than upgrade an existing system I should think about it from a new perspective, taking the things I love - and removing the things I hate - about WordPress. I should point out though that I’m not out to produce WordPress for ASP.NET, and I’m not creating a blogging platform. I want to create a content management system that implements a really solid blogging system.

So Byron is born. It’s an ASP.NET 2.0 application using a MySQL database. Why MySQL? Because Microsoft SQL Server is just too damned expensive. Why ASP.NET? It’s too long to go into, but it’s by far the more powerful language, at very little extra cost when looking at shared hosting. I’ll be writing it to support any form of database (or even a set of XML files), but this might not come till later in the development process.

I thought it’d be a great idea to blog the development process of this new project through from its conception to its first deployment and provide code snippets where they have value. If you’re not a programmer this will hopefully give you an idea of how a CMS is built, and if you’re a PHP developer this should show you that ASP.NET developers are real-world programmers.

I should point out that in an earlier post I extolled the virtues of systems like WordPress because of their “pick-up-and-go” style. That still stands. You can setup a new WordPress site in about five minutes from a standing start and that’s no mean feat, so I have nothing but respect for that system. It works too; really really well and the development community behind it is immense. I just think it’s important to put my skills on show on my own site.

Wish me luck!

A breath of fresh air

For the last 18 months or so I’ve been skipping from one host to another trying to find a company that didn’t cost the earth but also provided decent support. This is harder than you’d imagine.

My journey really started back in 2005 when I discovered , a small firm who I think were based in India. As I was an ASP.NET programmer I plumped for their .NET hosting which was - and still is - extremely cheap. It used a Plesk control panel which is great, and they had both instant chat and a support ticket system.

In all fairness the web side of things was OK on the whole: now and again the permissions I’d setup in Plesk would be reset and I’d have to go in and reinstate them, but the real problem was with their email services. There really is nothing worse than knowing you should have received an email but having no evidence to suggest this: hosts love that because there’s no mail to dispute (you can argue about a late email, but a missing one? forget it).

To cut a long story short, one of my clients complained so I found another host: . God they were great to begin with: cheap .NET hosting, free MySQL databases, instant chat, Plesk and a telephone number. I lapped it up, and ended up hosting about 8 sites with them.

I’ve recommended Dataflame in the past, and for small “set it and forget it” sites (minisites, static sites, email asset hosting) they’re great because you shouldn’t ever have to rely on their support...which is poor, to say the last. As I often do with hosts I started off very polite with lots of pleases, thank yous and complements, but I think the last online chat I had with one of their support guys (obviously stationed in an Indian call centre but given fake English names) ended with me calling him a bloody fool. Hardly offensive but not very professional either.

Not so long ago I decided to move this blog from wordpress.com to my own host, and thoroughly disillusioned with Dataflame and not willing to stump up the cash for a company like (who are great, but not cheap), and on a Twitter recommendation I signed up with , another budget host. And boy did they look budget! But the thing that attracted me was the distinct lack of an instant chat button and the welcome presence of a UK phone number. Could I be on to something here?

I’ve had two occasions to contact their support team and on both I’ve been really impressed. The first was down to my own ignorance but the second was a genuine problem that couldn’t be countered with their cPanel installation (the poor man’s Plesk). I got in touch and within an hour or so (on bank holiday Monday no less) the problem was resolved. Plus they were really polite and above all helpful.

I should stress though that this is not a .NET host but a PHP one (obviously the other hosts I’ve mentioned provide PHP but I was going for their .NET packages at the time), so I’m still stumped for a budget .NET host which leads me to wonder whether such a company exists. As I’ve mentioned I’m a big fan of Fasthosts, as I am of , but you’ve really got to reach into your pockets with those and they’re not great for getting a website out of the door quickly.

Embrace the change

I used to think of web apps like WordPress, FeedBurner and Flickr as tools for the uninitiated, the non-programmers, people who want a quick and easy website and a quiet life. I didn’t for a second begrudge the fact that fewer “techies” were contributing to the Web; my reasoning was that, by using these apps and linking to them on your site rather than developing the functionality yourself, you were sacrificing control.

And that’s still true. You can’t tailor Flickr to render your slideshow as you might want it - what if you don’t want cross-fading? What if you hate Flash? Blogger templates might be fiddly and WordPress is written in a language you might not be familiar with. But the question is: why does all that matter? Why does everything need to fit so nicely?

Do people look at sites that embrace these apps - sites like carsonified.com or jonbounds.co.uk who are both developed by developers incidentally - and think “well they obviously don’t know what they’re doing: they can’t even host their own videos!” or do they think “oh great, I love Twitter; let’s see what this guy’s up to”. I think the latter. Developers may still think the former, but they no longer hold all the keys.

In France, where the weather is good and people can stay up late, their houses are used only as a base: somewhere to lay your head til the next day when you can think about knocking off work and popping out for a baguette. So does a house you only use as a base need a TV and DVD player in every room or an en-suite in the master bedroom? Why throw so much mud at the wall if you’re never around to see it stick, because you’re off enjoying your city?

The Web works in a similar way. If you’ve got so many profiles in so many places - a site for your blog, a page for your photos, somewhere to put your videos - surely all you need a website for is to tie these things together? Yes maybe you want to muse on your particular subject for a few pages, or you’re implementing some cool functionality that doesn’t exist anywhere else, but do you need to write your own video player when there’s a perfectly good one at YouTube? Do you even need to organise setting up your POP3 email accounts when Gmail now gives you email at your own domain?

I’m really only talking about sites for people, not companies. I don’t think this way of working will affect the likes of amazon.co.uk or anything like that, but it’s a great way to go if you’re a one (or even 10) man outfit.

Think it over, and embrace the change!