I’ve noticed that there are two different ways developers locate private variables used by properties. One way is to locate the private variable next to the property that returns them and all other private variable located elsewhere.

#region Private fields

private string _Member;
private int _AnotherMember;

#endregion

#region Properties

private string _Name;
public string Name
{
get { return _Name; }
set { _Name = value; }
}

private int _Age;
public int Age
{
get { return _Age; }
set { _Age = value; }
}

#endregion

The other way is to separate all private variables, both the ones that are used by properties and the ones used by the rest of the class, into two different locations.

#region Private fields

private string _Name;
private int _Age;
private string _Member;
private int _AnotherMember;

#endregion

#region Properties

public string Name
{
get { return _Name; }
set { _Name = value; }
}

public int Age
{
get { return _Age; }
set { _Age = value; }
}

#endregion

There are problems and advantages with both approaches even though they appear minor. It has to do with the psychological difference between variables.

The psychological difference

Let’s say there are two different types of private variables – the ones used by properties and the ones not used by properties. Basically, there is no difference. A private variable is the same no matter how it is used, but the usage is what makes the difference.

A private variable used by a property is a sort of a placeholder that is only accessed through the property. Because of that, it only exists because of the property and can therefore be considered a part of the class’s interface.

A private variable that isn’t used by a property is used by multiple methods in a more interactive manor. It exists because the inner workings of the class needs it and it has nothing to do with the public interface.

The difference is psychological because a private variable is the same no matter how it is used. I don’t think there is a wrong way to do it and it all comes down to personal choice of the developer.

Personally, I use the first approach because I can’t ignore the psychological difference and thinks it makes my code more maintainable and easier to understand. I find it to be difficult to get an overview of a class that has all private variables grouped together, because they don’t tell me anything about how they are used. Then I need to find the references manually in the code and it just seems unnecessary in many cases.

Another thing is that I like to comment the different private variables, but only the ones that are not used by properties. The ones used by properties don't need to be commented because it is obvious what they do, but only if they are located next to their respective property.

Some years ago there was a lot of fuzz about the importance of the W3C XHTML standard. I’ve always been a firm believer of the standards and built every website to comply with them. But why?

Very brief history

The standards have made a huge difference historically speaking, because they helped eradicate browser specific mark-up to such a degree that it today doesn’t really matter if you use Opera, Firefox or IE. The same is true with the CSS standard to some extend. The next releases from the browser manufactures will be even more compliant until they reach ~100% and that is fantastic from a web developer’s point of view.

Strange selling points

Over the years I’ve heard a lot of strange selling points about XHTML, mainly from smaller web design companies. They tell you why they use XHTML and why it is a future proofing feature of their work. Some of these selling points make sense in theory, but is out of touch with the real world. Below are four of those selling points and why they don’t matter as selling points for XHTML.

Separation of content and style

The XHTML 1.0 and the CSS standard made an impact because it let to the separation of content and style. It is easier to maintain a website when the style and content is separated in different files. The same goes with JavaScript. It makes the pages smaller and quicker to download. The funny thing is that you can do that too in HTML 4.01. Smart yes, XHTML future proofing no.

XHTML is XML

One of the biggest lies about future proofing using XHTML is the argument that XHTML is XML.
Because XHTML basically is XML documents it means that those web pages are machine-readable using XPath.

Today, we know that we cannot rely on the XML validity of XHTML documents in general and therefore don’t see them as XML documents suitable for machine parsing. The DOCTYPE tells you one thing, but try to run the validator on an entire website and see how many errors it finds. Normally we use regular expressions to parse XHTML documents when we instead could have used XPath according to the selling point. But of course, we can’t.

Mobile platforms

Another great selling point is that XHTML web pages are readable on mobile devices or take very little modification to be. That was not correct 5 years ago and it still isn’t even though mobile browsers have become much richer such as Opera Mini and Pocket IE.

XHTML is more readable on mobile devices – not because it is XHTML but because its mark-up is simpler. The problem is that in the year of 2007, mobile devices are still terrible at CSS and JavaScript. The autopostback feature of many ASP.NET controls works only in Pocket IE because it uses JavaScript. Changes are that your existing XHTML website does not work on mobile platforms because it is filled with JavaScript and CSS.

The newest standard

XHTML is the newest HTML based standard so it will be easier and cheaper to upgrade to the next standard when it arrives. That’s also a good one. XHTML 1.0 is from January 2000 and has had a small upgrade to XHTML 1.1 a couple of years later. What is the average lifespan of a website compared to the lifespan of a W3C standard? I’ll bet that the website changes before a new standard arrives and even though it arrives before, which browsers will then be ready to fully support it and will it be backward compatible?

Yes, XHTML is the newest standard and it will be cheaper to upgrade, but it doesn’t carry much weight in practice and thereby isn’t future proofing.

The real selling point

So what is the selling point really? If it isn’t the machine readability, the mobile rendering, the newest standard or the fact that you can separate content and style, what then?

The reason I use it is because it has better cross-browser support in the DOM and it look prettier, but is that really a general selling point for an entire standard today? I’m not surprised by all the web developers who don’t care about XHTML when the selling point is so hard to find.