SubSonic 2.1

subsonic I’ve been using SubSonic for about a year now, and I’m a big fan. As the website says, SubSonic is a open source toolset for .NET developers that helps a website build itself. Essentially what SubSonic does is automatically generate your data access layer for you. It saves you from having to write the same boilerplate code over and over. Developers like to talk a lot about improving productivity, and SubSonic actually helps in that regard. The latest version, 2.1, was released on Tuesday.

SubSonic is known as an Object-Relational Mapping (OR/M) tool. What that means is that it generates objects that reflect your database structure. So if you have a table called “User” it will create an object called “User”. Unlike most OR/M tools however, SubSonic prefers convention over configuration. This is my favorite part about SubSonic – there are no mapping files! You don’t need to say that “User” is a table you’d like to use, and that the “Username” column is a string. SubSonic figures that out on its own. Everything just happens automagically.

I like to run SubSonic manually on the command line, so that I can stick the code it generates into a class library. You do this by running SubCommander. The objects SubSonic generates by default are Active Record objects. You use them like this:

User user = new User();
user.Username = "mastermaq";
user.Save();

The newest version of SubSonic also supports what’s known as the Repository Pattern, for developers who don’t like the Active Record way of working with objects. You can learn more about that here.

Also new in SubSonic 2.1 are query factories, which let you write fluent code like this:

return new Select()
    .From<User>()
    .Where(User.Columns.Username)
    .IsEqualTo(username)
    .ExecuteSingle<User>();

Doesn’t that look wonderful? It almost makes working with the database enjoyable!

If you are still writing your data access code by hand, I’d definitely suggest taking a look at SubSonic. If you’re using a different OR/M tool, you might want to see how SubSonic compares. It currently works with SQL Server 2000/2005/2008, MySQL, and Oracle.

You can download SubSonic 2.1 from CodePlex. Check out the SubSonic website for more information, and also Rob and Eric‘s blogs.

jQuery: Don't build websites without it!

jquery For the last few weeks I’ve been using a JavaScript library called jQuery. The more I use it, the more I wonder how I ever built websites without it! Here’s the official description:

jQuery is a fast, concise, JavaScript Library that simplifies how you traverse HTML documents, handle events, perform animations, and add Ajax interactions to your web pages. jQuery is designed to change the way that you write JavaScript.

jQuery makes all of your page manipulations easier. Best of all, it does so in a consistent, reliable way across all browsers. No more little hacks in your JavaScript to make something work in both IE and Safari.

In general, I’m a big fan of doing things client-side on the web. That might sound weird coming from an ASP.NET developer, since the whole idea behind ASP.NET’s postback model (called Web Forms) is to make everything happen server-side. I think most experienced ASP.NET developers would agree however, that the postback model is crap. It’s flawed, and if you can avoid it, you should.

We built Podcast Spot in ASP.NET, but we don’t use postbacks. ASP.NET is essentially just our rendering engine. We made use of prototype, another popular JavaScript library, but a lot of the code we wrote is just ugly. I wish I had known about jQuery back then. I’m tempted to rewrite everything using jQuery, but I’m mindful of the “if it ain’t broke, don’t fix it” adage.

It’s very unlikely I’ll be building anything new without jQuery though. That’s how much I love it! Here are my favorite things so far:

  • Works in Internet Explorer, Firefox, Safari, and Opera. Cross-browser support FTW!
  • At just 16 KB for the minified, gzipped version, it has a very small footprint.
  • The API feels natural if you already know JavaScript quite well.
  • Chainability – the magic of jQuery. If you’re familiar with object-oriented programming, you’ll love jQuery.
  • The jQuery UI API is much more consistent and complete than script.aculo.us, and the effects seem much smoother too.

To get started with jQuery, just visit the website. You’ll probably also want to take a look at jQuery UI. The documentation is excellent, and there are quite a few tutorials available online.

Something to keep an eye on: Microsoft Velocity

Last week I heard about a new project from Microsoft code-named Velocity. You can think of Velocity as Microsoft’s version of the very popular memcached:

“Velocity” is a distributed in-memory cache that provides .NET applications with high-speed access, scale, and high availability to application data.

Basically it’s a backend technology that helps to make websites perform better. Instead of accessing the database every time a page is requested, the website can often get the data it needs from the cache which is much faster than accessing the database.

ASP.NET has had caching built-in for years, but it doesn’t work in a server farm. That is, if you have more than one web server, there’s no way for all of them to share the same cache. Velocity makes that possible. For a good technical overview of Velocity, check out this post from Dare Obasanjo. Also check out Scott Hanselman’s podcast interview with two of Velocity’s architects.

We use memcached in Podcast Spot, and we’ve been very happy with it. It’s simple, efficient, and does just what we need it to do. Of course, our memcached installation is no where near the size of Facebook’s. I’ve read in a few places in the past that they run a 200 server cluster with 3 TB of memory solely for memcached. I’m sure it has grown since then too.

I have no idea how well Velocity will perform compared to memcached, or even if it’s full of bugs or not! I am eager to play around with it though, and it’s a project I’ll definitely be keeping an eye on. Velocity is a project from Microsoft that is long overdue, in my opinion.

Tutoring CMPUT 101 – Introduction to Computing

Post ImageA few months ago I was walking through HUB Mall at the U of A when I ran into an old friend I hadn’t seen since high school. We had a brief chat, and I of course told her about all of the geeky things I do. Turns out she was taking CMPUT 101 this semester (spring term), and asked if I’d be willing to tutor her. I said sure, not knowing what I was getting myself into!

Her final exam was today (hopefully she did well) so our last session was yesterday. Throughout her course we met twice a week for roughly two hours each time to go over the concepts she was learning in lecture, and to work on her labs. It was a really good experience for me, and she said my help was really important for helping her understand the material. Actually, she told me yesterday “you have a gift you should share! maybe you should join the tutor registry.” I think she was being overly nice 🙂

Here are some thoughts:

  • As this was an introduction course (that I never took actually) I really had to refresh my memory on some of the topics (like Two’s Complement). Mostly it all came flowing back to me though!
  • There were definitely some frustrating times, for her and for me! She would have trouble grasping a concept and I would have trouble explaining it. We worked through it though, and found a way for it to make sense. So I learned that tutors need patience.
  • I get the feeling that taking a computer course in a compressed term (spring or summer) is quite hard, especially if you’re not a computer-person! The content is just rushed.
  • I think tutoring a higher level class would be fun, where the student already knows the basics.

I know she’ll pass the course, so I am just eager to see how well she does! She gave me a gift card for Starbucks yesterday as a thank you – incredibly nice of her, but completely unnecessary!

I don’t know if I am going to join the tutor registry, but I’ll definitely considerate it now that I have some experience.

Clean & Hackable URLs

Post ImageA week ago, Roland Tanglao reiterated his love for clean URLs. Or perhaps more accurately, his hatred of dirty (?) URLs. Here’s what he wrote:

URLs with question marks, ampersands, etc should be banished to the Web 1.0 h*ll where they belong. I’ve been preaching the clean URL gospel for years but if I see one more WordPress blog with “?p” or one more Drupal site with “?q”, I’ll scream 🙂 Seriously if your webhost or your tech gal/guy can’t figure out how to use clean URLs, find somebody else. It’s 2007!

I couldn’t agree more. Here’s an example of what he means:

Dirty: http://example.com/articles.html?articleid=123&tag=rss
Clean: http://example.com/articles/123/rss

Clearly I prefer the second one, and I’m guessing you do too. I’m going to go one step further though, and say that not only should URLs be clean, they should be hackable! What does that mean? Let me give you an example:

http://mastermaq.podcastspot.com/episodes/FF7962/license
http://mastermaq.podcastspot.com/episodes/FF7962
http://mastermaq.podcastspot.com/episodes
http://mastermaq.podcastspot.com

The first link is for the licensing information of an episode. All you’ve got to do is “hack” off the end and you get the episode itself. One more hack and you get all the episodes. And finally, you’re left with the entire podcast. It’s pretty logical right? And it would be trivial to replace the episode ID with another one, or /episodes with /tags, etc. That’s what I mean by hackable – they are easily modified to get you where you want to go.

Here’s another example:

http://mastermaq.podcastspot.com/episodes/archive/2007/02/24

That will show you all episodes for February 24th, 2007. The URL is readable, and immediately you understand what it is doing. What if you want a different day? Replace 24 with something else. Just the month? Hack off the 24. You get the idea.

Clearly I am drinking the clean & hackable URLs koolaid, and as a result Podcast Spot has nothing but clean, hackable URLs. If you’re working on a web project, consider doing the same – your users will thank you for it.

Tim O'Reilly on Yahoo! Pipes

Post ImageI’ve been doing a little more reading about Yahoo! Pipes lately, and today I came across this excellent (though somewhat long) post from Mr. Web 2.0 himself, Tim O’Reilly. He says (via BoingBoing):

It democratizes web programming, making it easier for people to have more control over the internet information services they consume, and providing a general-purpose platform for interacting with sites that is more powerful than the browser or feed-reader alone, but without requiring full programming skills.

I think that’s a great way to describe what Pipes is, and why it matters. Sure the interface could be improved and made easier to use, but it’s only going to get better from here.

Read: Tim O’Reilly

Yahoo! Pipes

Post ImageI decided I would take one last look at Techmeme before heading off to bed, and as a result I just found out about a new product from Yahoo! called Pipes. It’s definitely not for everyone, but my inner geek is jumping for joy – Pipes is very, very cool:

Pipes is a hosted service that lets you remix feeds and create new data mashups in a visual programming environment. The name of the service pays tribute to Unix pipes, which let programmers do astonishingly clever things by making it easy to chain simple utilities together on the command line.

I just created a quick “pipe” to see how it works, and I have to admit, it’s very easy to use. Essentially it will let you take any number of sources (like an RSS feed or something), add user inputs if required, combine them with modules to process the data, and finally connect them all together to produce some output. And it’s all done visually. No programming experience required (well not really).

Nik at TechCrunch nails it:

Pipes can take any feed as input, and combined with the already available list of functions proves to be very powerful – my mind is still buzzing thinking about all that can be done with Pipes.

It was inevitable that such a product would be released, and it is very good for Yahoo! that they managed to be the first of the big web companies to release such a product.

I wonder how successful Pipes will be. Could it be the product that allows everyone to be a “programmer”? Possibly. Nik is right that the terminology needs some work (they use too many “coder” terms I think) but that’s fairly minor. Pipes has incredible potential.

I’m definitely going to have to play with it some more.

Read: Yahoo! Pipes

Simple advice for acting on your software ideas

Post ImageJustice decided to play the “hypothetical situation” game today, with a post asking what you should do if a great idea hits you. I started out writing a comment, but it got ridiculously long, so here’s a post instead. First, I’ll answer the questions Justice included in his post, then I’ll suggest some of my own questions. Not that you need to be reminded, but I’ll say it anyway – I’m not an expert on these matters, so take this advice with a grain (or jug) of salt!

Okay, so you’ve got a great world-changing idea for a software application/business. What now?

Do you even tell *anyone*?
Yes! This is the easiest of the questions to answer. I think you have to tell someone, preferrably many people. You might think your idea is amazing, and maybe it is, but you won’t know until you get someone else’s opinion. Be prepared though, an honest opinion from someone can have you hitting the ground hard.

If/when this occurs to you, what do you do?
Well, tell someone first. Get another opinion. After that, decide if you really want to proceed. I don’t like doing things half-assed, and I’m sure you don’t either, so this is really an “am I all in or not” kind of decision. It’s not quite the point of no return, but once you commit, you had better follow through.

How do you get started?
In the case of software (or most things of a technical nature), you need to help people visualize your idea. That means getting a prototype or mockup or something going as quickly as possible. It’ll help you refine the idea, and it’ll make it easier to attract help later on. If you don’t know any programming languages, I guess you should learn one of those first 😉

Do you quit your job immediately and begin laboring intensely to bring this to fruition?
This is a difficult question to answer. It comes down to opportunity cost I suppose. It really depends on your individual situation. If you can quit your job and still manage to keep a roof over your head and coke, er, food on the table while working on your idea, I say go for it. Be prepared to give up any social life you might have however!

One caveat is to make sure you have something else going on in your life. If all you do is work on your idea, you’re going to burn out. You need to be able to take a break every now and then.

Do you immediately rush out and try to gather every talented and qualified person you know to begin building what you understand will eventually end up altering the world for the better?
In short, no. First, get that prototype/mockup going. Once that’s done, you can think about adding to the team. Here are some of the things you need to consider:

  • A large team can actually slow you down!
  • Waiting too long to bring in other developers may mean they spend all their time learning what you’ve already done before they can become productive.
  • Make sure you’re ready to share the glory if you decide not to go it alone.
  • A small number of people with specialized, complementary skills can be excellent for development.
  • How will you pay everyone?

What other questions should you be asking?
Well, there’s a bunch. Here are some that came to mind for me:

  • What problem am I solving? This one you need to be able to answer right away.
  • Do I want to be rich or do I want to change the world? This will have an impact on how you decide to pursue the idea. If you’re lucky, you’ll get both.
  • If you decide to go for it, will you get a Pareto efficient outcome? Of course it won’t be perfectly Pareto optimal, but that should be the goal. If your family has to suffer greatly for this to work, maybe reconsider.
  • How much is this going to cost me? In dollars, time, etc.
  • Are you prepared to hear “no”? Because you will, a lot.
  • Do you value sleep? You’ll get less and less if you go after your idea.
  • If this becomes a real business, are you ready to give up control one day? You’ll likely need to bring in outside help, investors, etc.

There’s dozens of other potential questions you could ask. Most of them don’t need to be asked right away, however.

So, what now?
I really believe you need to do two things: create a visualization of your idea, and get as many opinions as you can. After you’ve done those two things, you’ll have a better handle on the idea, and you’ll be in a much better position to answer any questions.

Read: Gray’s Matter

Imagine Cup Canada 2006

Post ImageIt’s getting to be that time of year again! Microsoft’s annual Imagine Cup programming competition is starting to heat up, with thousands of students from around the world already registered. If you’re a Canadian looking to enter the Software Design Challenge, time is running out:

The Software Design Challenge is the most high profile Imagine Cup competition. This year, teams of young technologists are challenged to create the an innovative, impactful, and elegant piece of software to help people live healthier lives.

Register your team for the Software Design Challenge – you can register until April 7, 2006. Create your executive summary and submit it using the required submission template to ICcan@microsoft.com by midnight April 7, 2006. THIS is all you need do to secure your team a place in the most high profile category of Imagine Cup 2006.

Having competed in the past, I can honestly say that the Imagine Cup is an excellent experience for students who want to do some .NET programming (as in my experience, most schools do not teach .NET or C# or anything related). In addition to the Software Design invitational, there are also invitationals for IT, Short Film, Algorithm, and Interface Designer, plus the Project Hoshimi Programming Battle. Lots of ways to participate!

I think Dickson and I will be entering a team again this year, as it is our last year of eligibility and we think we have a great idea too. Of course, it is related to podcasting, but that’s all I’ll say for now.

Read: Imagine Cup Canada

JavaSchools are not the problem

Post ImageJoel Spolsky is one of the most famous and respected software development commentators, so when he writes an article, it is usually a good idea to take notice. His latest article, The Perils of JavaSchools, was published today and is definitely worth reading. I think Joel makes some good points, but I don’t agree with his entire argument. I don’t think JavaSchools, as Joel describes them, are the problem.

First, Joel mentions that in the old days programmers chose C as their language of choice whereas now they choose Java. His first claim is that Java “is not, generally, a hard enough programming language that it can be used to discriminate between great programmers and mediocre programmers.” He goes on to say that pointers and recursion, two of the most difficult concepts to understand, are no longer taught in so called “weed out” courses.

The lucky kids of JavaSchools are never going to get weird segfaults trying to implement pointer-based hash tables. They’re never going to go stark, raving mad trying to pack things into bits. They’ll never have to get their head around how, in a purely functional program, the value of a variable never changes, and yet, it changes all the time! A paradox!

The first problem with this argument is that pointers are rarely required anymore, and functional programming just isn’t used much. Joel himself identifies both of these facts. He also mentions that to work on an operating system, you pretty much have to understand pointers. That’s the second problem – while that may be the case today, it probably will not always be the case!

I don’t think that a programmer has to learn a really hard language with really hard concepts to be a great programmer. I don’t think it matters much if someone is an expert at recursion and pointers, or if they are an expert at object oriented programming instead.

How is anyone supposed to learn anything if the curriculum has been carefully designed to make everything easier than it already is?

I don’t think that you need to learn the hard way in order to learn anything.

The fact is, things are getting easier than Joel makes them out to be. Managed code is quite a bit easier to write than traditional unmanaged code, but that doesn’t mean it is limited. There is already a research project at Microsoft to build an operating system using managed code (almost entirely). And we’re inching closer and closer to a time when efficient programming is more important than figuring out all of the different ways to solve a problem and then finding the fastest one, or the one that uses the least amount of memory, or separating them on some other heuristic. We’re going to need rapid application development to get things done quickly.

Consider manufacturing. Do you have to know how all of the little pieces work together in a widget in order to make a useful contribution to the team building that widget? What if the widget has wheels, do you need to completely understand the wheel? All of the angles, the way it works, the problems it may encounter? I would argue that the best way to make a useful contribution is to specialize in a particular part of that widget, or even better, the process of building part of the widget. We’d be able to build far more widgets, far more efficiently, if everyone specialized in something than having to understand everything.

Medicine works the same way. All doctors have to learn the same basic stuff, but then they specialize in a particular field. The difference with computing sciences is that we don’t yet know what that “same basic stuff” should be. Is it object oriented programming, or something else? Certainly the conventional wisdom is that you should learn OOP, and thus we teach Java. The “same basic stuff” has become Java, and I have no doubt it will change again in the future.

Second, Joel seems to suggest that the only good programmers are ones with lots and lots of education.

But what about the CS mission of CS departments? They’re not vocational schools! It shouldn’t be their job to train people to work in industry. That’s for community colleges and government retraining programs for displaced workers, they will tell you. They’re supposed to be giving students the fundamental tools to live their lives, not preparing them for their first weeks on the job. Right? Still.

I can’t understand why the professors on the curriculum committees at CS schools have allowed their programs to be dumbed down to the point where not only can’t they produce working programmers, they can’t even produce CS grad students who might get PhDs and compete for their jobs.

I agree that CS students really should learn to do some actual programming rather than just theorizing about it. I don’t agree though, that a good programmer should be defined by their level of education! I think what needs to happen is a separation of what we currently call “computing scientists.” Those with the PhD’s, and those who like to do the research and try and wrap their heads around weird concepts should be the computer scientists. Those who are trained as good programmers, able to solve problems and actually implement solutions should be computer engineers.

Take my school, for example. We have Computing Sciences and we have Computer Engineering – but the two do not match up to the two types of people I just described. Currently, Computing Sciences encompasses both computer scientists and computer engineers. That needs to change. There should be different curriculum for each.

Joel says:

I’m going back to ones and zeros.

That’s too bad, because Joel is a very smart guy and could probably make a difference in how we move forward. The problem is not with JavaSchools. The problem is that the same school is trying to teach two totally different types of people.

Read: Joel on Software