Rory Primrose

I don't have a solution but I admire the problem

Recent Posts

Tags

Community

Email Notifications

Archives

November 2005 - Posts

Paint.Net 2.5 released

Rick and the crew have just released Paint.Net 2.5. The evolution of this product has been nothing short of fantastic. There are several things I like about the Paint.Net project. It is under constant development by a committed team, and they really listen to what the community wants in the product.

If you are after a paint replacement that is free, this app is gold. Grab it from the Paint.net site.

Unpredictable control rendering is never a good thing

Probably the things I struggle with most in the IT industry (and usually when looking for a new job) revolve around the questions of:

  • How good am I?
  • How much do I know?

These questions are really hard for anyone answer although having a degree and/or other certification helps to indicate what you should know.

Following from these questions, I have often thought about whether I would be good enough to work for this company or that company. Take Microsoft for example. Would I be good enough for them? I don't know, but I like to think that they are the benchmark for a programmer's skill as they are a leader in the industry. Every now and then though, I come across some Microsoft code where I can't really understand why they developed something the way they did. This time, I have come across how checkboxes and radio buttons render themselves in ASP.Net 2.0. I would like to know whether there was some kind of valid design reason for the rendering behavior of these controls or whether it is just, in my humble opinion, poor design.

The inconsistency of these controls is around whether a SPAN tag is rendered around the control. In ASP.Net, almost every control is surrounded by some type of parent tag. Against this parent tag, attributes like id, class, title and styles are typically rendered. The parent tag renders an HTML structure that represents the control as an entity. A client-side script developer can reference that parent tag and understand that it represents a control and any children it contains. A page developer can assign styles and CSS classes to the control based on the HTML structure and expect a consistent style behavior to be implemented.

The radio button control inherits from the checkbox control and the only major difference between them is how they render their INPUT tag. The checkbox and radio button controls render an INPUT tag (as expected) and a LABEL tag if there is a Text property value. The SPAN tag surrounding the INPUT (and optional LABEL) tag will only be rendered if there is a class value, any style values, the control is disabled or there are custom attributes assigned to the control. If none of these cases are encountered, then there is no SPAN tag. What this means is that there may be a parent tag, or there may not be.

This inconsistency will become a problem especially when classes are used in tags above the control in the HTML hierarchy and selectors are used to style the input fields. Take the following ASPX declaration for example:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

    <title>Untitled Page</title>

    <style type="text/css" media="all">

 

        .TestClass span input

        {

            border: 1px solid black;

            margin: 15px;

        }

 

    </style>

</head>

<body>

    <form id="form1" runat="server">

        <div class="TestClass">

            <div>

                <ASP:CHECKBOX id="chkTest1" runat="server" />

            </div>

            <div>

                <ASP:CHECKBOX id="chkTest2" runat="server" text="Test 2" />

            </div>

            <div>

                <ASP:CHECKBOX id="chkTest3" runat="server" tooltip="different structure" />

            </div>

            <div>

                <ASP:CHECKBOX id="chkTest4" runat="server" text="Test 2" tooltip="different structure again" />

            </div>

        </div>

    </form>

</body>

</html>

The intention behind this example is that the INPUT tags will be styled with a border and margins based on a CSS class assigned further up the HTML hierarchy. The CSS class and selector is saying that where a tag is found with the CSS class of TestClass, apply the style to any controls like checkboxes and radio buttons. This demonstrates a likely scenario where the developer is under the assumption that a checkbox will always render a SPAN tag as the parent element.

When this is run, the HTML output is this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title>Untitled Page </title>

    <style media="all" type="text/css">

 

        .TestClass span input

        {

            border: 1px solid black;

            margin: 15px;

        }

 

    </style>

</head>

<body>

    <form id="form1" action="Default.aspx" method="post" name="form1">

        <div>

            <input id="__VIEWSTATE" name="__VIEWSTATE" type="hidden" value="/wEPDwUKMTU1MjcxNDA3NWQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0Qm

Fja0tleV9fFgQFCGNoa1Rlc3QxBQhjaGtUZXN0MgUIY2hrVGVzdDMFC

GNoa1Rlc3Q0073yAnmuscc5SVp45f2hz4h5v5k=" />

        </div>

        <div class="TestClass">

            <div>

                <input id="chkTest1" name="chkTest1" type="checkbox" />

            </div>

            <div>

                <input id="chkTest2" name="chkTest2" type="checkbox" /><label for="chkTest2">Test 2</label>

            </div>

            <div>

                <span title="different structure">

                    <input id="chkTest3" name="chkTest3" type="checkbox" /></span>

            </div>

            <div>

                <span title="different structure again">

                    <input id="chkTest4" name="chkTest4" type="checkbox" /><label for="chkTest4">Test 2</label></span>

            </div>

        </div>

        <div>

            <input id="__EVENTVALIDATION" name="__EVENTVALIDATION" type="hidden" value="/wEWBQLW6MyrCwKtweqtDQKtwa6cAwKtwcL3CwKtwaa/BzjQrPLOlUVjvfSfhjgmYNkpkQmM" />

        </div>

    </form>

</body>

</html>

The first two checkboxes don't apply the style, but the other two do. I am sure that there will be developers every now and then that can't figure out why their selector based styles are not being used for their radio buttons and checkbox controls. If the Microsoft developer of these web controls was consistent and always rendered a SPAN tag as the parent element, this wouldn't be a problem.

Posted: Nov 23 2005, 05:55 AM by Rory Primrose | with no comments
Filed under:
So it was a bug

One of the things that I didn't like about Whidbey was the apparent lack of support in the designer for implementing interfaces. In the prior versions of Visual Studio, when you implement the interface, all the signatures of the interface are put into the code document automatically. This support seemed to be ditched in Whidbey. I started to get a little confused about this feature because sometimes it did work. I assumed that it was buggy Beta and CTP versions that were responsible.

Now I am using the RTM version, I am still having this behavior. I have just figured it out though and it is a bug. If you implement the interface inside a region, the signatures are not auto inserted. If the implements statement is typed into the class outside any regions, the signatures are added.

Posted: Nov 20 2005, 10:18 AM by Rory Primrose | with 1 comment(s)
Filed under:
Tricky paging - Learning something new everyday

My team lead sent us an email with a link to http://smh.com.au/articles/2005/11/02/1130823242025.html. He stumbled across a cool bit of functionality when he copied the contents of this five page article. He found that if you select the entire page, copy it to the clipboard then paste it into a program (like notepad), then all five pages of the article are pasted into the document (although this doesn't seem to work when pasting into Word though).

How does this work?

Firstly, the contents of all five pages are in the source code for each page downloaded. The contents for each page is surrounded in a DIV that has a class and an ID that identifies the page number. There is a script in the page that looks for a querystring that indicates the page number. It loops through each page content DIV and shows or hides it as appropriate. There is a stylesheet reference in the page defined as media="print" that includes a reference to the css class. This class ensures that when the document is printed, all the page content DIVs are rendered.

So that covers displaying the correct page in the browser, and also printing all pages. What about copying it to the clipboard?

I originally thought that a copy operation was using the media="print" stylesheet. With a little testing, it seems that this is not the case. A copy seems to ignore the display style and goes off the HTML defined instead. In the case of this page, a copy has the same effect as the media="print" stylesheet in that all page content DIVs are included.

Whether the copy behavior was understood by the developers or not, it is a very cool side-effect.

Opinionated or Passionate?

There are several things that I mark up as me being passionate about. From a technical point of view, these include coding, OOP, .Net, VB, great looking UI, controls, smart clients and so on and so forth (always wanted to say that but it is a bit long, should now be referred to as ASOASF).

Outside of these things that I am passionate about, there are several things that I have always considered as me being opinionated about. Coming up with the best design for something, be it an application, component or a control is probably the one that sticks out most and tends to get me into the most disagreements in the workplace. I can't stand poor design (even though I probably come up with enough of them myself). I am often discussing/fighting for the best design with other people, regardless of whether they are workmates or my managers. It doesn't matter to me. I think it is more important to do a good job and get the most appropriate design than be a 'yes' man. I will explain my position and argue the point until I a) get what I want; b) get an acceptable compromise or c) someone pulls rank and outbids me.

The point here is that because I put my opinion out there, I considered myself opinionated. I saw it in a negative light. I guess this was because I was disagreeing with other people's ideas. That is until yesterday.

I was discussing some issues with the lead of a build team and someone else at work. I was giving one of my opinions and I tried to ease the opinion into the discussion by saying '...., but I am just opinionated'. The build team lead corrected me by saying that I was passionate, not opinionated. I thought about this for a second. It's true. I haven't been opinionated for these last six or seven years in the industry. I have been passionate. I want the best results.

The other guy in the conversation replied with 'in your opinion...'

It's all about customer service

What picks one business from another?

Especially after there has been some history of customer interaction involved, it comes down to customer service. In this latest edition of 'Who wants my business', I have had to deal with Sunglass Hut and Oakley.

My wife bought me a pair of eye jacket Oakley's about seven years ago for my birthday (you get to choose which one). They cost about $160 at the time and have been worth every cent. They have however finally come to the end of their days. The frame must have just become too brittle in its long life and the frame broke above one of the lenses.

My first port of call was Sunglass hut. What are my options? I know it isn't going to be a warranty thing and I am happy to pay to get them repaired. After being sent away twice because the salesperson was busy with a difficult sale (I don't actually have a problem with this bit), I was told that without a receipt they wouldn't be able to send it away for repairs.

First problem here is that it is for a repair job, not a warranty job, yet I still need the original receipt. The reasoning provided was that too many people have bought fake sunglasses and brought them in for repair. This, for some reason, resulted in cost to the business so a receipt policy was put in place.

Second problem is that they were bought seven years earlier. I may have the receipt, but it might be just a little difficult to find.

Third problem with this policy is that even if I did have a receipt, it doesn't prove that the sunglasses being repaired are the ones that the receipt represents. I could have bought a fake pair since and wanted the fake set repaired.

Fourth problem is that their 'new' computer system only keeps records back to 2004. So if I don't have a seven year old slip of paper then I'm stuck because their database doesn't store enough historical data.

They suggested that I contact Oakley if I couldn't find the receipt because I would probably have to deal with them directly. When I got back to the office, I checked out the Oakley website. There was a contact us link there so I sent them an email. I outlined the situation and asked what I should do about it. When I sent the email, I was thinking it was a long shot and I would probably have to call them later anyway. After all, what kind of big business deals with the little people via email?

Within two minutes of sending the email, my work phone rings. I answer and it is someone from Oakley. They wanted to let me know what my options were.

From a customer point of view, Sunglass Hut have presented me (albeit pleasantly and apologetically) with four barriers in our customer relationship. Oakley on the other hand presented options, and did so with such swiftness that I almost couldn't talk when I answered the phone (you know when you answer the phone and your brain tries to understand the situation and catch up to the conversation again - perhaps that's just me).

Needless to say, I was incredible impressed with the customer service of Oakley.

12 breaks and other such fun

I have been learning lots of new things at Taekwondo over the last couple of months. The pace has really picked up as well so it is quite a workout.

To progress from blue belt (1 tip) to purple belt, I have had to learn three patterns/poomse and lots of board breaks/gyokpa. For patterns, I learnt Sa Jang, O Jang and Yuk Jang. Yuk Jang is definitely my favourite at the moment.

Board breaking has been a lot of fun. We practise with re-breakable plastic boards, but we use treated pine boards in the graduations. The pine boards we use are 1.8cm thick which is thicker than the standard. Depending on the strike being used, the board dimensions for adults are 27cm x 27cm or about 18cm x 27cm (I think). It gets a little harder where there are knots in the wood because they don't break as easily. On the flip side though, some boards can get small rot lines which makes it easier to break. Because I grade with the other instructors, I tend to get the knotted boards that everyone else rejects from their graduations.

Other than the three patterns, I have done 12 board breaks in the last two weeks for my purple belt grading. Last week I did right and left hand strike and right and left down kick. Last night I did right and left jumping ball kick and right and left punch break (don't want to do that too often :)). Tonight, I finished off the breaks with right and left knife-hand strike and right and left jumping down kick. After all that, I have only come away with one sore knuckle (punch break with a knotted board plus my fist angle was ever so slightly off). I am really looking forward to flying side kick breaks, but I think I have to wait until red belt for that. I am probably not to far away from that though.

I have really enjoyed the last couple of months of learning and training with new techniques and moves. Tonight was the payoff because I was awarded purple belt.

It has been interesting reading Sara Ford's blog (she is about to go for black belt in Karate). It's been great to read other peoples experience with other martial arts and gradings. I would like to read other tech bloggers who are into martial arts, but there don't seem to be many around. If you know of any, let me know.

My club has also launched its site. If you are interested in Taekwondo in Canberra (Australia), check out the Lantern site.

Posted: Nov 03 2005, 09:17 PM by Rory Primrose | with no comments
Filed under: