Archive for August, 2004

 

The Blog Reader’s Guide to the Hitchhikers’s Guide to the Galaxy

Aug 31, 2004 by Graeme in Fun

Hey! The official web site of the HHGttG film has a blog! No RSS feed though, but maybe I’m hoping for too much from a load of ape descendants who still think digital watches are a pretty neat idea… :(

Gmail for laughs

Aug 28, 2004 by Graeme in Fun

I’ve got some spare Gmail invites to hand out. If you want one, add a joke as a comment to this post. Those who post the best jokes will get an invite!

Make sure you email me your email address if you don’t have a user account, otherwise I won’t be able to invite you.

Half-Life 2 NOT going gold on Monday

Aug 28, 2004 by Graeme in Fun

Dammit! The rumours were a result of someone guessing Gabe Newell’s password (sorry, no permalink - look for Fools Gold) on the Half-Life 2 Fallout forums.

Olympics

Aug 28, 2004 by Graeme in Fun

I’ve enjoyed the 2004 Olympics like never before. I suppose it helps when the Brits thrash the Yanks in the 4×100m relay by a whole 100th of a second. How exciting was that? :)

Maybe by 2008 we’ll even have it in 16:9 ;)

Lightweight boxing final tomorrow… Come on Kahn!

.NET Undocumented

Aug 28, 2004 by Graeme in Development

Somehow I didn’t spot Wes’ blog until about a week ago. Good, well thought out stuff which has inspired me to write a couple of posts already. I wonder who else is out there? :)

A bit of nostalgia - MetaCode

Aug 28, 2004 by Graeme in Development

A post by Wes reminded me of an idea I had back in March 2001. After some discussion on the DevelopMentor mailing list (I think there was just the one .NET list back then) I wrote up a summary and gave it the rather grand sounding name of MetaCode. Here it is…

What is MetaCode?

The MetaCode vision

Source code of today is, for the most part, plain text. We all bash away at
our notepad-derived text editors, struggling to format our code, keep it
syntactically correct, and place useful comments within it. This is hard work.
Developing software is hard enough without these extra chores.

MetaCode attempts to reduce the
complexity of this juggling act by allowing the developer to concentrate on the
logical structure of the code. Formatting, code documentation, and validity checking
"just happen". The MetaCode vision is of a completely new
representation of code. XML is the technology which makes this possible.

I’d like to explain further by talking about each part of the problem in
turn.

Code

Code has structure. Code is structure. Our namespaces contain classes
contain methods. Why, then, do we continue to use plain text for our source
code? Plain text has no structure.

Developers put a lot of effort into trying to represent structure in plain
text source code. We spend too much time indenting blocks, making sure our curly brackets line up, word wrapping
our comments, and generally making things look acceptable. This is a lot of
wasted effort. Still, when we’re done we have our nicely formatted, commented
source code.

What do we do then? We hand our pretty source code to a compiler which
promptly strips out all of our comments and formatting so that it can
concentrate on the semantics of the code. So, the compiler doesn’t care how our
code looks; if we can somehow overcome our own need to have beautiful code then
we can save ourselves a lot of trouble.

Why do we feel the need to format our code? What do we get for our efforts?

  1. Structural information. We use indentation to show the structure of our
    code. This helps us understand how our code works when we are reading it.
  2. Documentation. We get information about the code where we need it most -
    with the code.
  3. RSI ;)

How can we get these benefits without formatting our code? The structure we
need exists in our code whether we choose to show it in formatting or not. Why don’t we use
this built in structure instead of attempting to duplicate it with our
formatting?

XML has proven itself as a syntax for representing hierarchical data in a
textual format. We can use XML to represent our code.

For example, take the following code snippet:

class MyClass : BaseClass
{
	// This method returns a number. It isn't a very useful example.
	int MyMethod()
	{
		return 0;
	}
}

We can represent the same information like this:

<class name="MyClass" base="BaseClass">
	<method name="MyMethod" type="int">
		<description>
			This method returns a number. It isn't a very useful example.
		</description>
		<body>
			return 0;
		</body>
	</method>
</class>

At first it appears that all we have done is sacrifice some readability. But,
we have gained the ability to read, understand and create our code in other
ways. We can:

  1. Read our code with any XML parser - this makes writing code to manipulate
    code very easy
  2. Process our code with XSLT to produce our original plain text source code,
    ready for compilation
  3. Process our code with XSLT to produce documentation
  4. Edit our code with an XML editor such as XML Spy which can understand and enforce the structural rules of our code
    as we edit it

So, MetaCode replaces the structural syntax of the programming language with a
standard, simple, widely accepted structural syntax; XML.

Documentation

I touched briefly on documentation a moment ago. However, the problems and
potential benefits in this area are worth further discussion.

We try to document our code in several ways:

  1. We add comments to our source code. Comments are difficult to format, are
    restricted to plain text, and are difficult to find and read. These problems
    tend to sap the developer of his good intentions, and they are either omitted
    or become out of date.
  2. Because our code comments are inadequate, we attempt to maintain separate
    documents describing the code. These supporting documents are invariably out of date.
  3. Ideally, we produce a UML model of our code. In my experience, unless your
    UML tool makes round trip engineering effortless, this suffers from the same
    problems as supporting documentation.

MetaCode addresses these problems by combining the code and its documentation
into the same document. This brings the following benefits:

  1. The documentation is always complete, accurate, and up to date.
  2. Much of the valuable documentation describes the structure of the code. We
    no longer need to document this as we can generate our documentation from the
    code itself.
  3. We can annotate our code with any XML data we like - so we can embed XHTML
    (or anything else) if we wish to go beyond the plain text we are stuck with
    today.

Of course, there is nothing to stop you continuing to write supporting
documents and UML models.

Example

Here’s the ever popular Hello World program in MetaCode for C#:

<namespace name="Microsoft.Samples.WinForms.Cs.SimpleHelloWorld">
        <using namespace="System"/>
        <using namespace="System.WinForms"/>
        <class visibility="public" name="SimpleHelloWorld" base="Form">

                <method visibility="public" static="true" return="int" name="Main">
                        <summary>
                                The entry point for the application.
                        </summary>
                        <parameter type="string[]" name="args"/>
                        <body>
                        Application.Run(new SimpleHelloWorld()); return 0;
                        </body>

                </method>
                <method visibility="public" name="SimpleHelloWorld">
                        <summary>
                                Does something really useful.
                        </summary>
                        <body>
                                this.Text = "Hello World";
                        </body>

                </method>
        </class>
</namespace>

Conclusion

MetaCode replaces traditional structural syntax with XML. This allows code
structure to be processed by the multitude of XML tools available today, and
makes writing new, specialist tools trivial. It encourages good documentation by
providing a consistent, logical place to write annotations alongside code.

Games going gold

Aug 28, 2004 by Graeme in Fun

It’s an exciting time to be a gamer… Both Fable
and The Sims 2 have gone gold, and the rumour
mill says Half-Life 2
might go gold as soon as Monday
.

I’ve got Fable pre-ordered and Half-Life 2 pre-loaded, but The Sims 2 will have
to wait for now. There just aren’t enough hours in the day.

I’m particularly looking forward to Half-Life 2, even though my 18-month-old laptop probably won’t be able to do it justice. The original Half-Life is my favourite game so far. I remember playing it night
after night when my wife was pregnant with my son - it helped prepare me for the
horrors of fatherhood. ;)

Avalon for XP

Aug 28, 2004 by Graeme in Development

So Avalon will
be available as an update to Windows XP
, as well as remaining in Longhorn. Excellent news for developers!

Let’s face it - Avalon would have been a real pain if we still had to develop for
Windows Forms in order to support Windows XP. Of the new technologies which were
to be part of Longhorn, Avalon probably has the potential to touch the broadest
range of applications, including rich clients and traditional desktop applications. I don’t have time to develop the UI twice, so I’d be stuck using Windows Forms until
Longhorn took a large enough share of desktops to drop support for the others. Only then would my new projects be able to take advantage of Avalon.

But now we’ll be able to target Avalon much sooner, without requiring an OS upgrade, and we’ll still have the option to target Longhorn if need be. Win-win! :)

Shame about WinFS, but I’d rather it was done better than sooner.

NUnitAddIn updated

Aug 24, 2004 by Graeme in Development

Jamie has updated one of my favourite development tools. Get it here!

Gametrak: Real World Golf

Aug 22, 2004 by Graeme in Fun

SPOnG reports on Gametrak’s PS2 and PC motion-tracker:

Also confirmed for a Q1 2005 release is Gametrak: Real World Golf. The concept is simple: choose a club and swing it. It’s been a long time in the works, but this is sure to appeal to many people who wouldn’t normally spend their time playing videogames. The sort of people, for example, who play golf. Whether or not Real World Golf could actually serve as a useful training tool for real world golfers will remain to be seen, but it is an interesting possibility.

I hope so. Something’s got to work. :)