Visual Studio Snippets: More trouble than they’re worth?

tribbles This week, a post on the Joel on Software forum asked if Copy-Paste can be considered code reuse.  This one caught my eye, since I went through an exercise just last week to automate exactly this sort of thing.

I hate copy-paste programming.  Generally, if you're doing this, it means you should refactor that code to encapsulate it and just call the routine where needed.  Last week, though, for a variety of really bad reasons, I had to insert a bunch of repetitive code, and I'd already extracted and encapsulated everything I could.

"This calls for Snippets,' I said.

Have you seen Snippets?  They're the tribbles of Visual Studio development.  Microsoft introduced this cute little toolbox where you can keep all your little chunks of magic, and then recall them and drop them into your current context at a moment's notice.  If they're so cute and tiny and wonderful, then, what could be bad about trib -- er, Snippets?

All light-hearted ribbing aside, I think it's worth pointing out one last time that most of the time you think you need to copy and paste a bunch of times, you probably really need something different.  Find a base class to overload, or even use a custom attribute.  But every once in a while, you really do need to be able to paste in some code and change it up a little -- over, and over, and over.  In these cases, Snippets are a pretty nice way to do it.

Rotten Apple: Brainwashing in a black turtleneck

rotten_apple_smIt's been a "best of times, worst of times" year for Apple.  There's no denying the swell they're seeing from the iPhone, new iPods, and a new release of OSX.  Apple stock looks pretty golden in a fragile market.

And yet, if you're paying attention, there are some cracks in the facade.  One by one, people are starting to notice the little problems that other companies get crucified for.

Early examples were problems with iPhone activation, phone bills, and firmware updates.  Recent examples:

  • Fear and Loathing Is Not A Great Brand Image
  • Update: More Leopard Problems Plague Apple
  • A true story about my Mac
  • And finally, me.  A few weeks ago, I lost a hard drive.  I have a backup of all of my important stuff, but I didn't have a backup of this drive, because it contains stuff I can generally replicate from other sources.  This drive had my iTunes music on it, which I could generally reproduce by re-ripping all of my CDs, or (I thought) just plugging my damned iPod back in to my computer.  I was wrong on that last count.  I plugged my iPod back in after I rebuilt my PC, and iTunes said, "I need to purge this foreign content -- everything must go!"  I literally couldn't sync my iPod again until I wiped it and reloaded my music.  On top of everything else, I also lost all my song rankings, so I've got to "re-train" my iPod to know the music I like most.

So what?  Lots of companies have problems like this.  They work through them, and the move on.  Why would Apple be any different?

Apple's different because they convinced us that they're better.

In late September, Robert Scoble posted when some people's iPhones were bricked during an updateI blogged a response back then, and I left a comment explaining why people were more upset about these problems with an Apple product than they'd be with someone else's product:

But Apple?s supposed to be better than Microsoft. That?s their hook.


Let?s face it - an important part of the Apple mystique is the experience. Stuff just *works* when it?s from Apple, right? When people start to question that image, it?s a blow to the brand.

I suspect this isn't something that Scoble didn't already know, but I'll take credit for planting a seed, because he came back and hit this topic again this week (The brand promise of Apple).  Here, Robert starts to look at a new facet of this dynamic: Apple users love Apple so much that they'd sooner believe they're idiots than to think that Apple's done something wrong.


If there ever was any question about the marketing prowess of Jobs, this should put that to rest.  This is really good stuff.  Since the very first marketing consultant crawled out of the primeval soup and began surveying dentists, this is the holy grail they've sought.  It's lightning in a bottle, and it's the engine that drives Apple.

A handful of brands have achieved a measure of this success over the years.  Saturn was there when they first hit the scene, and to a lesser degree, the new Beetle.  When you hear about kids beating other kids to steal a pair of shoes, this elixir is at work.

When it happens, it makes people a little nuts.

And so it is with Apple.  People see only good, and look past the rotten, let alone evil.  When iTunes refuses to recover my music, or even my song ratings -- content that I generated on their hardware -- I'm not supposed to feel angry or alienated or betrayed.  I'm supposed to subserviently ask for forgiveness on behalf of my ill-behaved PC.  I had it coming for running Windows, anyway, right?

As soon as people start to question the infallibility of Jobs, Inc., the whole brand begins to look vulnerable.  This is a fragile ecosystem, and it's dangerously close to meltdown.

How do you feel about Saturns today?

Don't think that I'm writing this because I hate Apple.  On the contrary, I think the magic they've shown us over the last five years or so is the stuff legends are made of.  Very, very few of us will ever have a chance to achieve anything like the run Apple's had recently, so I believe we've all got a lot to learn from them.  Among the things we can learn, though, is how tough it is to do what they've done, and how quickly it can be lost if you're not careful.

For another great analysis on this balance, check out this article: Apple: What Could Go Wrong

Steve McConnell on Technical Debt

Architecture has always been a tough sell.  Except in rare cases, it's not a feature that makes the front page of the color glossy sales brocures.  Even though a failed architecture is deadly, it always seems like a struggle to allocate time and budget to invest there instead of adding more features.

Steve McConnell manages to capture the "pay me now or pay me later" dynamics of architecture far better than I ever was able to in this article about Technical Debt.  By recasting a technical subject in terms taken from the Wall Street Journal, he captures the business risk involved here in a way that a CFO can grasp.

If you're an architect, you've got to read this article.

Reblog this post [with Zemanta]

The Future of ASP.Net

mvcOver the last couple weeks, I've seen some announcements in the blogosphere that tell me that some winds of change are a-blowin', and we're going to see some really positive developments in ASP.Net tools and techniques in the coming months and years.  These improvements aren't about adding capabilities, they're about making the capabilities we've already got accessible to more developers.

The C# / ASP.Net platform circa Fall, 2007 is  astoundingly capable.  If there's something you can't do with this platform, you just haven't tried hard enough.  But this power too often comes at the price of coding complexity, or just as bad, coding overhead.  If I've got to write seven layers of infrastructure to get something done, I'm not too excited about doing it anymore.

The promise of a platform like .Net is that it should support both low-level code jockeys and higher-level applications developers who are working with the business on a daily basis, because the end-game is business productivity.

Enough preamble.  First development: Scott Guthrie's ASP.Net MVC Framework.  If you've read this blog for any length of time, you'll know that Scott's blog is a must-read.  His announcement of an MVC framework for ASP.Net is major news, though it was easy to miss.  So what's the big deal?  Lots of people have done some form of MVC in -- why's this one any different?

The simplest answer is that this one, with any luck, will be the one MVC Framework to Rule Them All.  In short, there's a lot of value in having this become a standard for ASP.Net development just so that people don't have to worry about trying to do this themselves anymore.  Unless someone has needs so completely out-of-the ordinary that this framework is off the table, it's in as a default.  Fewer decisions = more productivity.

As a second-order benefit, I hope to see UI development move away from the "one big ASPX file per web page" model, toward a more component-oriented view.  Think about the way a screen is constructed in a CMS or something like Facebook or Myspace.  This is a whole lot more modular and flexible, but it'll require a shift away from the way most pages are put together.  Go read this and see if it sparks some ideas.

The second big news flash is related.  There's a guy named Rob Conery who's been working on an open-source data-access toolkit called SubSonic.   I almost referred to SubSonic as an ORM, but I think that wouldn't quite capture the spirit of SubSonic.  In any event, the news here is that Rob is going to work for Microsoft.  He'll be working in Scott's group, in fact.

Again, so what?  Again, it's about throwing enough weight and credibility behind SubSonic that it becomes an acceptable, if not brain-dead architecture choice.

pic27753Let me explain.  There are lots of other tools and frameworks out there that compete with SubSonic on some level.  I don't care if one of them is seven percent faster or requires eleven percent fewer lines of code.   What I care about is that SubSonic (and many of the other tools in this space) are better than working with ADO.Net alone.  But while this product space is fractured and chaotic, none of these tools will be a clear leader.

For me as an architect, that means that every time I'd like to use one of these tools, I've got to explain to someone that (1) it's a really good idea, (2) it's better than any of the other seventeen alternatives - including scratchbuilding, and (3) it's going to stand the test of time.  Let one of these tools win, and that argument goes away, and I can get on with building systems for business users.

And that makes me happy.

So all of this stuff is a done-deal, right?  No, of course not.  We'll have to watch these developments play out a bit.  Scott's blog targets the first-half of next year for the MVC Framework.  Rob is at Microsoft now, but we won't see any industry consolidation around SubSonic for a while yet.  But Microsoft's endorsement, even if only implicit, gives SubSonic some momentum.  I can't wait to see these bits working together.

Further reading:

How MVC, jQuery, and SubSonic Will Make You Smile
SubSonic: MVC Preview Video
Code Magazine ASP.NET MVC article
Microsoft's interesting "embrace" of Windows Open Source

Wherefore Art Thou: GotDotNet

gotdotnet When Microsoft introduced the .Net platform, they clearly wanted to reach out to the developer community and build some connections.  The "Start" page in Visual Studio and the "Community" menu sort of show what they were aiming for.  About the same time, the "" site showed up.

GotDotNet was a community site built for MS developers by MS developers.  To be honest, I don't know what involvement, if any, Microsoft had with this site, but it was clearly a good thing for Microsoft, since it gathered like-minded developers together and gave them a place to share tips and techniques.  There's no doubt that it added value for Microsoft by promoting its tools and covering some support burden via peer-to-peer support.

Time marches on, though, and a year or so ago, the folks running GotDotNet decided to ramp it down.  Other sites were to take its place, like Codeplex to host community-build code bases, and so on.

One big problem remains, however: GotDotNet continues to dominate search results for the stuff it used to have, and there's no forwarding address if you want to find this "old" material.

Case in point: Code Snippets for C#.

I'm dropping some timing code into a project, and it's repetitive work.  It occurred to me that this was exactly the sort of thing I'd expect a "snippet" to handle:

DateTime timr = MyLog.BeginTimingMessage("Unnamed timer", 0);

<< code to time >>

MyLog.EndTimingMessage("Unnamed timer", 0, timr);

So I Google "c# snippet", and the top results point at a blog hosted on (so I assume he's an MS employee, MVP, or equivalent).  The post is dated 2005, and it talks about a snippet editor called "Snippy".  It's apparent at this point that snippets are slightly more complicated than just chunks of text - hence, the need for an editor.   That's fine, I thought - I'll just go grab the editor and be on my way.

So I follow the link in the blog to GotDotNet, and see this "so long, and thanks for all the fish" message:


Great.  I did my best to find a breadcrumb trail leading out of this abyss, but to no avail.

In this case, it turns out it wasn't the end of the world.  I never did find "snippy", or any other snippet editor, for that matter, but I found the MSDN documentation that let me create the XML from scratch.

But the thing that really bugged me was that Microsoft would let this play out the way it did.  How much effort would it really have taken them to step in here and find new homes for the files on this site and to provide forwarding links to guide people to the new homes?  Don't they have interns??

Here's a site that's got a bunch of top Google spots for searches about Microsoft development topics.  All sorts of Microsoft developers are going to hit these links, and they're going to be spending real time navigating around on a wild goose chase for community content, all the while muttering about how they wouldn't have this problem if they were looking for something on Sourceforge.

It's a blown opportunity for Microsoft to take care of the developers who are driving the demand for their products.

Easy come, easy go.

Is OpenSocial a big F-U to Microsoft?

There's a huge amount of news today about Google's new OpenSocial platform API.  It turns out that everyone but Facebook has already announced that they're on this bandwagon.  So what?

Does anyone remember the big news about Facebook just before this whirlwind hit??  Remember Microsoft paying out buku-buku bucks for a percentage stake in Facebook?  Remember that??  Facebook valued at $15B??

I'm really surprised that nobody's asked this yet, but do you still think Google would've rolled out OpenSocial if they'd won that bidding war instead of Microsoft?

Pause for effect.

Ok, so realistically, there's probably still a decent chance Google would've introduced this platform at some point, but I'd bet that Facebook would have been on board.

What's going to happen here?  If OpenSocial shows any signs of momentum at all, Facebook is gonna be on the thing eventually.  But -- Facebook loses its big shot at world domination.  After all, a couple weeks ago, people were talking about Facebook knocking Google off the top of the hill, and they were almost serious.

That's gone now.

You know what else is gone?  Facebook's $15B valuation.  Poof!

Ballmer's got to be three shades of purple in the face right now.

It's a big-stakes chess match out there, and this was a money move.