I’m Wasting My Montior

I know I’m wasting my 24” widescreen monitor, but I don’t like the layout of the following markup.

<asp:TextBox runat="server" ID="txtPasswordExisting"
   TextMode="Password" />
<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator2"
   CssClass="error" ControlToValidate="txtPasswordExisting"
    Display="Dynamic" Text="Username is required." ValidationGroup="AssociateAccount" />
<cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender7" runat="server" TargetControlID="RequiredFieldValidator2"
    HighlightCssClass ="error" CssClass ="validatorCallout" />

I would prefer this.

<asp:TextBox runat="server" ID="txtPasswordExisting"
    TextMode    ="Password" />
<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator2"
    CssClass            ="error"
    ControlToValidate   ="txtPasswordExisting"
    Display             ="Dynamic"
    Text                ="Username is required."
    ValidationGroup     ="AssociateAccount" />
<cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender7" runat="server"
    TargetControlID     ="RequiredFieldValidator2"
    HighlightCssClass   ="error"
    CssClass            ="validatorCallout" />

…OK. It doesn’t display nicely in the syntax highlighter because of the proportional width font, but you get the idea.

I’m sure in most people’s mind it is wasted vertical space, but it makes doing diffs so much easier and my eyes easily see the grouping of controls and their attributes.

4 Comments so far

  1. Steve on April 16th, 2009

    Diffs will be very hard if someone else comes along who does not like this way and reformats things like that to their own personal liking instead. Didn’t you and I run into trouble with that a few times? I remember heated battles over where the opening curly brace was “supposed to go”. :)

    http://www.codinghorror.com/blog/archives/001254.html

  2. mark on April 16th, 2009

    That’s true. The team just needs to standardize on something and go with it. I don’t think people would like my method though.

    ReSharper makes this easy by letting you include the formatting settings in a file that travels with the solution.

    Good diff tools (not the crap one that comes with TFS) will be able to highlight difference in a single line, but I still like this method better. My eyes don’t move over the entire set of attribute values to find the one I’m looking for.

  3. Sean on April 16th, 2009

    If you really care enough, couldn’t you describe how to format XML to your liking very precisely? I suppose your editor could give you the view you prefer. Couldn’t it also map your changes back to the original document by discarding foldable whitespace?

  4. mark on April 17th, 2009

    @Sean Beyond Compare is nice enough to ignore whitespace in a single line, but not nice enough, as far as I know, to ignore new lines as well.

Leave a Reply