I'll be presenting a session at the San Diego Code Camp this Saturday (6/30/07) titled "Using SubSonic to built ASP.NET applications that are good, fast, and cheap". I'll do a quick overview SubSonic in general, but spend most of the time building out a website. If you're interested in following along on you laptop, be sure to grab of SubSonic 2.0.2 (the latest release)from CodePlex.
I got the bright and early 9 AM slot, but am convinced that coffee will see us through.
UPDATE: Files from my talk are available here.
Twitter is Good Enough
Twitter drives all my tech-savvy friends crazy. We all agree that the idea - a simple mix of blog, chat, and IM - is a good one. However the site does very little, and what it does it does poorly - slow response, frequent outages, etc. Most developers figure they could write a "better Twitter" in a lazy afternoon, and some already have. Good idea, poor execution, and yet... it's good enough.
Twitter is good enough to keep its network and remain successful. Yes, they could be better, but their networked customer base isn't going to pick up and move to a new service all at once, and people are unlikely to move on their own. Twitter is good enough.
The Dishwasher, the Chinese Room, and a Subservient Chicken
Assume I told you to specify the very first dishwashing machine. It would be very tempting to define the process:
- The machine will pick up an article.
- The machine will wash the article.
- The machine will inspect the article for spots and re-wash if necessary.
- The machine will rinse the article.
- The machine will dry the article and place it on the drying rack.
In reality, though, dishwashers just spray a bunch of hot, soapy water on dishes in a rack and dry them with hot air. They don't deal with the dishes one at a time, which is part of the reason that they're small enough and cheap enough to fit in most kitchens.1
Imagine that you needed to design a system which acted on a small set of instructions which were written in Chinese. You don't speak Chinese. What would you do?
The "right" answer might be to hire some translators, or possibly set up some automated translation software. Those would all work, but would probably be a little expensive. What if I told you that it was acceptable to have a small percentage of failures, especially at the beginning? In reality, a most software is not 100% perfect, especially in early versions...
I didn't randomly pick this task. The Chinese Room is a famous thought experiment in artificial intelligence, which postulates that a person with a good enough "cheat sheet" in a sealed room could pretend to be conversant in Chinese, even though they didn't have any idea of what they were saying. That would be work even better if the vocabulary and topics were confined2.
That's how the Subservient Chicken worked. The Subservient Chicken was an advertising campaign for Burger King's chicken sandwiches back in 2004. You could (and still can) give the chicken just about any order, and he'd do it. It was amazing... and yet, the chicken only performed about 300 actions. They were just the right actions to make it look like this crazy guy in a chicken suit could do just about anything you asked of him.
Good enough for an a publicity stunt, but let's take it a step further. Let's say that we wanted the translator in the Chinese room to pretend to speak the entire Chinese language, and the Subservient Chicken to do just absolutely anything you could think of. In considering our approach, remember that a certain amount of failure is acceptable.
In that case, I'd make sure that the initial feature set (Chinese vocabulary, set of chicken stunts, etc.) would be just enough to keep users coming back, putting more effort into making sure all failures were captured and immediately acted on. Yes, the system won't be perfect to start, but it will keep improving, and the improvements will be based on what users are asking for that we can't handle. And in this case, I believe a quick feedback loop would be better than trying to guess what users would want for the initial release. That's how I assumed the Subservient Chicken worked, by the way. I figured that they had some guy acting out things as they came in, only performing new stunts when they weren't already in the system. If you did that, you'd very quickly build up a library of the most common requests, and a small amount of effort would be required to keep the system growing.
Ever wonder how Google's spell correction system works? If you search for "mnokey", you'll see "Did you mean: monkey", right? Although there are a few corrections to the results, the spell corrections don't come from an intelligent system or even a dictionary; they come from tracking user behavior. Just about every time someone searches on "mnokey", they don't click on any search results and search again for "monkey." Google tracks that and uses that as a good guess at a spell correction. The system learns from users.
Everything's a feature
So, what features are up for discussion? Absolutely all of them.
- Security is a feature
- Reliability is a feature
- Performance is a feature
- Scalability is a feature
- Object orientation is a feature
- Test coverage is a feature
- Data integrity is a feature
- Data access methodology (e.g. only via stored procedure) is a feature
- Etc., etc.
Some of those are obviously listed to provoke a reaction, but everything on the above list really is negotiable.
For instance, you might see security as non-negotiable, but Wikipedia is a pretty good example of a site with an intentionally weak security system which has become incredibly successful.
Reliability? NASA shoots for zero defect products. It's enormously expensive, and it's not always successful. Every major Internet service I use crashes or goes offline from time to time. Nobody's 100% reliable. If we say reliability is non-negotiable, we're fooling ourselves.
Performance and scalability? As Richard Campbell and others pointed out during the ASP.NET Scalability Panel, it's a big mistake to spend too much effort supporting millions of users when you don't have a hundred. Of course we should avoid irresponsible programming, but I recommend building working systems that can be tuned when needed rather than building elegant systems from day one.
I understand that many developers view that as sloppy programming, but that's just following personal preference over pragmatism:
- Premature optimization is nearly always misguided
- Which is worse - a horribly inefficient system which has gone live, or a beautiful system which goes to market late enough to be irrelevant?
- Most successful software systems (Windows, Google, MySpace, etc.) shipped in an imperfect form followed by lots of incremental improvements.
I'm really into performance tuning - I wrote a section in our soon-to-be-released ASP.NET book focused on tuning slow ASP.NET applications, from caching to database profiling to index tuning. I enjoy writing SQL, and I think I'm really good at it. And yet, I'm a big fan of SubSonic, which generates dynamic SQL for ASP.NET data access. That's because, while I like hand-crafting SQL queries, I think it's usually an irresponsible waste of time. The better approach is to build a working application on a framework which allows me to hand tune when I need to, then wait until that time comes to get under the hood. It takes restraint to let facts rather than gut tell me where to spend my time, but it's the right thing to do.
So, everything on the list above (and more) is negotiable. Some are undoubtedly important in your application, but it's probably a mistake to try to get all of them perfect on the first release. Ship something, listen, then ship something better!
Network Effects and First Mover Advantage
So, Twitter shipped the first service "social chat-IM-blog" thing, and it's not perfect. Unless they're offline for days at a time or a competitor comes up with an absolutely stunning new feature, though, their network is secure because nobody wants to move to a new system without their friends. Inertia is on the side of an established network.
That's why it kills me to see Microsoft so late to the game with a lot of their Internet services. In many cases, they really are better services, but they're late enough to have a very uphill climb.
What I didn't say
I want to make it clear that I'm not saying programmers should write poor software. We all know that will happen without my saying so... What I am saying is that software teams should focus on shipping software quickly that's "good enough" to be useful to their customers as quickly as they possibly can, then use customer feedback and actual system performance to drive what happens next.
1 I first heard this example studying for my old-school MCSD six or seven years ago. I no longer have the book and can't find the quote online, but I think it's a fantastic analogy.
2 I learned the value of limited vocabularies in my days as a submarine officer. We all got pretty used to communications under terrible conditions - sound powered telephones in the engine room, ship to ship radios, yelled verbal reports during fire and flooding casualties (some of which were drills, some of which weren't). The trick was that we were trained to use very specific terminology. That's great for several reasons - the speaker doesn't have to make any decisions on how to phrase your words, and the listener doesn't parse sentences so much as select from a few possible expected commands or responses. Hmm... this sounds like a separate post...
Last night I made a simple Silverlight maze generator for my 6 year old daughter, who's really into mazes right now. When I tried to print the resulting mazes, I found that the Silverlight content was was blank in Firefox (left), but worked in IE (right):
I'm thinking a better error message might be in order when folks try to view Silverlight 1.1 content with managed code and only have Silverlight 1.0 installed, but for now this is what you get (obviously the last three lines will vary depending on the actual XAML content):
I had trouble restoring a SQL Server 2005 Analysis Services backup today due to "Errors in the metadata manager" messages:
The ddl2:MemberKeysUnique element at line 243, column 28420 (namespace http://schemas.microsoft.com/analysisservices/2003/engine/2) cannot appear under Load/ObjectDefinition/Dimension/Hierarchies/Hierarchy.
Errors in the metadata manager. An error occurred when instantiating a metadata object from the file, '\\?\C:\Program Files\Microsoft SQL Server\MSSQL.2\OLAP\Data\...
This requires Silverlight 1.1 Alpha, available here. If you only have Silverlight 1.0 installed, you'll get a wacky error message (AG_E_RUNTIME_MANAGED_ACTIVATION).
Click on the maze to start, then drive the blue dot to the pink dot.Use the arrow keys to move, or the following if you'd prefer:
UP: W or 8
LEFT: A or 4
DOWN: S or 2
RIGHT: D or 6
Each time you solve a maze, you get a harder one, until they're so microscopic you run out of pixels.
Since SubSonic data access code and cuts way down on the repetitive grunt work, I've started to resent having to write any code at all. On a recent project, we found that since we weren't writing much data access or map related objects, the majority of the code we had to write revolved around shuttling data between controls and object properties.
Rob Conery recently posted on Creating a Web Service-Enabled Login Silverlight Control, which is probably a more important topic than many people realize right now. Since Silverlight code runs client side in the user's browser, many tasks like database access and user authentication require what is by definition a "web service" (even if it uses REST or some other, non-ASMX approach).
Along the way, Rob ran into an interesting issue. Being the wise man that he is, Rob knew that he faced a choice:
- Figure out an odd brain teaser dealing with undocumented alpha technologies
- Mention the odd brain teaser to Jon, who would likely get hooked and stay up all night figuring it out
Rob's a smart guy, you guess what he chose...
The Orcas Beta 1 install kept failing on my laptop with a non-specific error. The install log didn't say anything very helpful:
Microsoft Web Designer Tools:  Component Microsoft Web Designer Tools returned an unexpected value.
setup.exe:  ISetupComponent::Pre/Post/Install() failed in ISetupManager::InternalInstallManager() with HRESULT -2147023293.
VS70pgui:  DepCheck indicates Microsoft Web Designer Tools is not installed.
A client needed some help with a display issue on Safari / Mac. Browsercam is a good solution and is reasonably priced, but for this simple issue I just needed to see the site in Safari / Mac and make sure I hadn't affected IE6 as well.
XAML uses a vector graphics markup which is very similar to SVG, but since it's part of a complete application framework the designers decided to use a slightly different format. I'd expect that XAML would be able to load SVG, or that there would at least be plenty of tools to convert SVG to XAML, but it was tougher than I thought. After some background, I'll discuss some solutions I found.
VB.NET gets a hard time from C# developers. For a variety of reasons, the leading .NET programmers seem to be working in C#, and VB.NET developers get really tired of saying, "Hey, VB.NET can do that, too!"
My friend wrote me last week to tell me about the astounding new feature Google Maps had added - Street View!
One of the coolest things I saw at MIX07 was on a Linux computer. Miguel was showing us something on his laptop when all of a sudden the desktop turned into a cube and started spinning around. Miguel told us it was Compiz, which has been available for X Window System (GNOME, KDE) for over a year now. Sidenote: A lot of people know it by the name of a fork of Compiz named Beryl. It sounds like Beryl is basically Compiz with a neater name and a better website. Anyhow, Beryl has rejoined the Compiz trunk.