Thought for the Dazed

I've had to give up that Distance Learning course as I was having trouble seeing the teacher.

Flickr
www.flickr.com
RobMiles' items Go to RobMiles' photostream
Twitter
C# Yellow Book

Search entire site
Wednesday
Nov082006

C# 3.0 and Stronger Magic

Warning: This is a techie heavy post. If you are after witty prose and belly laughs then I suggest you look elsewhere (but then again - what are you doing here in the first place).

Just been to the presentation by Anders Hejlsberg about what C# will be doing in the future. I took a bunch of notes on the mobile phone which I've tidied up to post here (apologies for typos and spelling errors that got through):

Extensions

You you can add a method to an interface. Then any object that implements the interface can use the method. Extension methods are brought in with the interface by means of a using statement. You can add them to classes too. Serious potential for stupidity/confusion here but also a lot of power. What I call a Spiderman situation (With great power comes great responsibility).... You may end up leaving the impression that your extension is part of C# itself. I wonder if anyone has thought about colour coding the intellisense?

Talking of Intellisense (the bits in Visual Studio which suggest what items you might want to enter at a given point in the code) it seems that it is now part of the language design in that there is an inherent assumption by the language that it will be there for the programmer.

Var

The var keyword lets you simplify the deceleration process. The type of the thing that you are making is inferred from the type of the expression on the right. In this respect it smells a bit like the dim statement in Visual Basic, but there is a bit more to it than that. It underpins a general principle that you can manipulate items for which you have not specifically created a type, but from which the compiler can infer the required information to make sure that your code has integrity.

Lambda Expressions

Lamda expressions let you pass code as a parameter to a method. Sometimes you need to tell a method what to do. In C# you usually need to create a delegate type which you then point at a method which does the job. With a lambda expression you can put the behavior right in place. There is no need to make a delegate.  

Object Initialisers

Object initialisers let you set initial values during declaration of an instance. Can also initialize collections.

Expression Trees 

These are scary. They let me manage code as data. The compiler will produce the tree based on a lambda expression it is given. It ends up as a bunch of atomic actions which you can pass around as data. You can also modify the tree or produce one of your own from scratch. You can also compile these into IL or use them to make things like SQL statements. This is how we get our C# program code mapped into database queries for the Linq stuff.

Automatic Properties

Not sure about these, they just seem to save you typing. They let you create properties directly without needing to produce the get and the set right at the start. Must have both get and set, but you can make set private if you want a read only property. You can also put real methods in later.

Linq Database Access

This is perhaps the jewel in the crown of the C# upgrades. Query expressions use context sensitive keywords to map the query into method calls. This happens during compilation. Linq uses lambda expressions to denote the selection criteria. 

A query result can deliver a result as an  anonymous type (created based on the context of the result required). Because this class implements things like IEnumerable (so you can work through it) you can use the var keyword to create variables to work on the data. C# will be able to infer the required type. This means that you don't need to create loads of classes just to deal with query results.

There were some good code examples which show how queries are mapped onto code. And the other good thing is that if you download the whole thing and play with it yourself.

Wednesday
Nov082006

Darned Efficiency

It seems that the time synchronisation betweeen diary and time zones has just about been sorted out. I know this because I set my alarm an hour early on my PDA to allow for the fact that I am in a different time zone, set my PDA to the correct time zone and then got my wake up call an hour early.

Drat.

Wednesday
Nov082006

You're Using a Q1 for that?

Last presentation of the day found me at a talk about the use of ink in Windows Presentation Foundation. This was a lovely presentation, not least because of what the speaker was using to run all the demonstrations.

He was running big chunks of the show on a lowly Samsung Q1. This is an ultra-mobile PC which you can just about fit in your pocket (if you have a big jacket). He swore that, over and above some slightly fancier hardware for the pen, his was a very standard machine, with only 512Mb of ram. Notwithstanding these limitations it proved quite happy to run all the demos, including the 3D one at the end, as well as Visual Studio, all sitting on top of Windows Vista.

This left me determined to put Vista on my Q1 when I get home. I don't have the fancy touch screen stuff, but I do have an extra 512Mb of ram, which should be interesting...

The talk itself was about how Windows Presentation Foundation supports ink. Unlike the original Tablet PC, which was forced to shoehorn ink in alongside all the other user interface gubbins, with WPF ink is an equal partner as far as the programmer is concerned. Couple this with the fact that all the WPF pages are rendered as vector items (no nasty size dependence and infinite scalability) and ink starts to look very viable in the future.

Tuesday
Nov072006

Qn: When is a protocol stack not a stack?

Ans: When it is a "framework".

Had a very good talk about Windows Communication Foundation.

This is the means by which software shall talk to software in the future. And jolly good it is too. For me the most impressive thing is the way that they have used the features of C# (interfaces, attributes etc) to make it easy to set up connections and select the components that you want to use in any given situation.

When I was a lad there was much talk of protocol stacks. I even wrote a song about the ISO/OSI seven layer stack for one of my world famous lectures in rhyme....

But these days things have moved on, and now the talk would seem to be of "frameworks". I think these are a bit like stacks, but laid on their sides and with the ability to have extra bits (like security and compression) plugged in alongside.

It does seem very easy to link two process on the same or different machines and it looks as if this technology will make a lot of hard wraught code redundant as it takes away a lot of the difficulty in linking programs together.

Tuesday
Nov072006

Windows Presentation Foundation Fun

Just been to a presentation on Windows Presentation Foundation. This is the thing that I've been using to write a message system for the department. I thought I'd go along and find out how the grown-ups do it.

The answer is "Very well indeed". I was kind of pleased to find that my basic understanding of the way things work (describe how it is going to look in one file - the XMAL and what it does in another file - the DLL) was pretty much right. However, what really blew me away was how far you can take this stuff in skilled hands, and with the right tools.

It also opened my eyes to the potential for 3D and so the message system might be going to get even prettier. And something else that I'm going to find out more about is the statement that WPF is going to be available for mobile devices. That, my friends, is seriously interesting......