Sergio and the sigil

Don't be sloppy in your scripts

Posted by Sergio on 2008-11-14

For a few weeks now, every time I try to logoff from my home banking website something bad happens. See screenshot below.(screenshot eaten by backup failure.)

  1. Firebug opens unexpectedly
  2. There's a frigging debugger; statement in the live production site
  3. The logoff process hangs until I press F8 in Firebug or the continue button
  4. All my information is still on the screen. Imagine if I had just clicked Sign Off and left my desk.

When I saw this for the first time I though: wow, some developer will be slapped for that (actually there are some developer names in the file,) but it seems that nobody else has a debugger enabled or they just hate their clients that are also web developers. The "bug" has been there for at least 2 weeks now.

Even if you don't care for customers that happen to have a debugger like myself, leaving that kind of thing in your production environment immediately projects an image of sloppiness that is the last thing I want to have with my home banking.

Update 11/24/2008: That script was fixed sometime over this past weekend.

Video - The Langston's Ant

Posted by Sergio on 2008-11-14

Remember one recent post when I talked about the Code Kata that I attended? Well, Micah prepared a screencast version of that Kata and that video is now available.

It's a short screencast (14') and even if Ruby is not your cup of tea, it's interesting to watch BDD being practiced.


Langston's Ant in Ruby Kata from Micah Martin on Vimeo.

Video - Core, an AOP Framework

Posted by Sergio on 2008-11-07

Wow, that took a long time to be published, but here it is. This video was recorded during the October's meeting of Chicago ALT.NET that happened almost just about a whole month ago.

The video shows Josh Heyse demonstrating and explaining the works of the AOP framework called Core. What the video doesn't show is who's that voice that also knows a lot about Core. That would be Anthony Green, who developed Core with Josh.

The people behind the bytes

Posted by Sergio on 2008-11-03

I think that any developer that creates customer-facing software dreams that their users rave about and show affection for the product. But being users of software ourselves we know it's not easy to like any application that much. There are usually so many other applications vying for our love, and they tend to be so bland and similar, it's easier to just treat them with equal disinterest.

SIDE NOTE: This reminds me of how much I miss Kathy Sierra's Creating Passionate Users blog.

Still, why some applications win your heart?

I would argue that this has all to do with the way such application let some of the hearts and souls that created the application leak through some inoffensive outlets.

The idea is that it is hard for users to attach themselves to something that has no sign of human behavior. Let me try to clarify this point with an example. Let's say Albert is your co-worker. He gets his job done but not always the same way every day. Sometimes he's not in the mood for water cooler chat, worried about the world financial crisis, sometimes he's thrilled that his team qualified for the playoffs, sometimes he's supportive when you are facing some personal problem. I mean, he's not a machine.

Take one of the biggest examples of them all: Google. Do you think the Google Doodles or the famous hidden treats are there just the works of mischievous coders? No. They are carefully placed messages that serve as a constant reminder that the folks at Google are real people and they like to connect with you, the user. What other email site would dare to have user message like "Hooray, no spam here!" ?

Why am I talking about this?

I've joined a new company a couple of months ago and I was pleasantly surprised to learn that we make use of those little outlets to connect to our users on a personal level as well. For example we change the site logo on special occasions and send plush toys to customers when we release a new version (plush toys, as a "weapon" of Marketing, deserves its own post. I'll leave that for another day.)

You may think this just sounds silly, but you should see the emails we get from customers when they notice these little things. They are thrilled to find them. Sometimes it makes someone's day. It happened again last Friday (Haloween — a major occasion in the U.S.)

It's very rewarding and I'm very proud to work with people that think about their users that much.

ASP.NET MVC and NHaml

Posted by Sergio on 2008-10-29

I started playing with NHaml lately for sheer curiosity. It comes with MVCContrib and that's what I've been using to explore it.

I'm not completely on board yet that you'll want to write all your views, for all kinds of application scenarios using NHaml. I know someone will probably jump out and say that their entire site was built with NHaml and it's wonderful. I'm sure it can be done, I'm just still wondering if it's more trouble than necessary. On the other hand, if you are starting a new application from scratch (i.e. you are not inheriting any existing template or that sort of thing,) then NHaml can guide you through a different way of thinking about your views and simplify them a lot.

I might have already said this before, but I'm generally in favor of working as close to the platform as possible and viable. That's why I'm not a big fan of things like Script#, RJS, and Volta. NHaml is almost in the same category but it does bring some nice things to the table and that's why I'm not ready to dismiss it just yet. Just take a look at what our HTML looked like circa 1998 and what it is now with richer CSS and JavaScript.

As much as I can, I try to separate my (X)HTML from my CSS and my JavaScript. Sometimes it gets to the point that I wonder why I am using HTML to begin with — it's all data and structure. I wonder how long until we have a WikiText or MarkDown view engines.

NHaml fits well for these kinds of well-separated HTML views. It does away (kind of) with the HTML tags and focus on the structure and meaning of each piece of information. Because it defines structure in a way that works well with CSS, it also works great with jQuery for our JavaScripts. It's unobtrusive JavaScript heaven!

I think the key to learning NHaml is forgetting about HTML and its tags (or at least don't focus on them). Forget that the page ultimately rendered will be in HTML. For a moment just visualize the areas of the page as meaningful pieces of data: sidebar, lists, headings, article title, article body, author name, navigation tabs, etc, not divs, tables, spans, fieldsets, etc.

Less Noise More Content

The most obvious impression you get when looking at a NHaml template for the first time is how skinny it is compared to any tag-based template. Your eyes are used to look for angle brackets to help you understand the structure of the document, but in NHaml the indentation serves that purpose.

Take a look at a common template to create a grid of products in ASPX.

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<title><%= ViewData["pagetitle"] %></title>
	</head>
	<body>
		<h1>All Products</h1>
		<table class="grid" id="products">
			<tr>
				<th>ID</th>
				<th>Name</th>
			</tr>
			<% foreach(var prod in (IEnumerable<Product>)ViewData["products"])  { %>
				<tr>
					<td><%= prod.ID %></td>
					<td><%=  prod.Name %></td>
				</tr>
			<% }  %>
		</table>
		<input type="button" value="Say Hi" onclick="alert('Hi');" />
	</body>
</html>

Now take compare that to the NHaml version.

!!! XML
!!!
%html
  %head
    %title= ViewData["pagetitle"] 
    %body
      %h1 All Products
        %table.grid#products
          %tr
            %th ID
            %th Name
          - foreach(var prod in (IEnumerable<Product>)ViewData["products"])
          %tr
            %td= prod.ID
            %td= prod.Name
        %input{ type="button", value="Say Hi", onclick="alert('Hi');"}/

Never Forget a Closing Tag Again

Having meaningful indentation brings the common advantage of needing to explicitly mark the end of a block, making that automatic. In other words, the closing tags are added at the right places for you. That's something I value a lot.

Identifiers and Selectors, Css-Friendly

By now, after looking at the above NHaml sample a few times, you probably noticed that the class and id attributes are set using a dot and a # sign, respectively.

%table.grid#products