Planning the Spontaneous

It's more than just a blueprint.

Catchup: limit++

Posted by Robert Chow on 05/10/2009

So, after having already written a couple lengthy posts, I thought I’d finished, then it struck me.  I haven’t.  Only a couple more things I wanted to show you.

Windows Presentation Foundation
(WPF, pronounced wu-puff)

This is the new windows form that Microsoft offer – it pretty much takes the old window form, which was very Win98-esque, to a more present level – something that looks a lot like Windows XP/Vista.  And I presume similar to Windows 7, but I haven’t quite got that far yet.  I’m currently working with a tool from Tao, the SimpleOpenGLControl, which is a preset device-context for rendering to.  Later on (or quite soon rather) I’m going to have to change from the SimpleOpenGLControl, to making the window from scratch.  From therein, to then present it in a WPF window.

SimpleOpenGLControl in WPF.  This image has been taken from

To get to grips with WPF for now, we have started work on a WPF designed repository browser for the Buzzard Framework – the framework which my supervisor has created.  The WPF itself is quite easy to get to grips with really.  It uses a language called xaml, and looks quite similar to xml.  True, I don’t really have any experience with xml, but I’ll learn.  Then the really cool bit is the code-inline/behind.  The code that actually makes it work.  Of course, we haven’t quite got onto that bit yet – the repository browser is the least of my priorities.


NANT is a build script which we can use to automate builds, without having to go into VS itself and build the file.  I guess it works in a similar way to the build scripts I used to create in Linux last year, but it seems to be a lot more formal, structured.  The main problem I ran into, when running the build script was accessing the VS command prompt.  There doesn’t seem to be one in the express editions, so a quick hack around of placing the VS properties into the windows enviroment variables had to be done.

One last thing. The things in C# are just bizarre. But great too. I keep on being told to take a dynamic language (python, Ruby, etc), but I’m still getting to grips with this!

The ternary operator ?

You might have noticed the title of my last post as a little confusing (I couldn’t resist).  Much so.  Consider the next statement.

x = (y < 1) ? y : 1

Doesn’t really make sense if you’re not used to it.  But it is essentially an assignment of a variable, after the evaluation of an if statement.  It’s exactly the same as:

if (y < 1)
x = y;
x = 1;

To simplify – x = (conditional) ? true : false;
That’s 8 lines into 1.  It’s great isn’t it!

Nullable? Types ??

Last thing.  I promise.  C# have introduced the concept of nullable types.  Makes sense really.  The integer value of 0 isn’t really a null value – it’s still there, it’s just 0.  The great thing about nullable types in C# is that they can be checked really easily, without the need of an if statement, by using the ?? operator.

int? i = null;
int j = i ?? 0;

So what does this mean?  The first statement is declaring a nullable int – done with the ? after the int.  This is saying that the variable i can either take in any integer value (within the computational limits), or take null as a value.  The second statement declares a normal int, and therefore cannot be null.  It is assigned the value i holds.  But wait.  That cannot be for i is null, and j cannot hold a null value.  The ?? operator checks to see if i is null.  It i is not null, then j is assigned the same value as i, as per usual.  However, if it is null, then, because j cannot hold a null value, it looks at the next option – in this case, it is a 0.  Therefore j is assigned the value of 0 (which is not null!).

I know the past few (well, only) posts have been quite brief and quite technical.  I am primarily doing this for my final year report, and for my personal reference – I find it easier to search in a document on the computer, than it is to find something in a book of scrambled notes.  It should hopefully all make sense when I come to write the final thing.  From now on, the posts should hopfully be a little bit more exciting because I’m not having to rush 2/3 months into a few paragraphs!


One Response to “Catchup: limit++”

  1. […] where I mention WPF a few times, but never really got into it?  Here’s a statement from the Microsoft […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: