2007-09-29

Derived properties that you don't want cached

I'm rewriting a Win32 application using ECO. One of the things this application allows the user to do is to specify their preferred unit of measurement for height, distance, depth, weight, and speed.

To achieve this I have an ECO class ApplicationSettings which is a singleton which identifies the units to use. I then have 2 properties for each value....

InternalLandingDistance
DisplayLandingDistance

The idea is that I should never expose Internal* properties in the GUI but display their corresponding Display* property instead. The Display* property will read/write the Internal* property and perform some kind of conversion on it.

If I always store my values using the unit with the highest accuracy (Distance = feet, Depth = millimetres, Weight = Pounds, Speed = KPH) then I just need to convert them by the correct factor when reading/writing from the Display* properties.

This isn't rocket science, obviously I can just implement these as reverse derived attributes right? The problem with this is that I am using a new EcoSpace per form, so if someone changes the ApplicationSettings.DistanceMeasurement in one EcoSpace my derived member has no way of knowing unless I want to put in synchronisation.

Well, my app can work stand-alone or on a network. I don't want to over complicate things, so what I decided I needed was a reverse derived property with no subscriptions + caching, but that just isn't possible.

Well, actually, it is. It's just so obvious! Instead of marking my members Derived I marked them as Transient and HasUserCode. I implement the code like so.....


public float DisplayLandingDistance
{
get
{
return ConvertDistanceToDisplay(InternalLandingDistance);
#if NeverDoThis
{EcoModeler generated code here}
#endif
}
set
{
InternalLandingDistance = ConvertDistanceToInternal(value);
#if NeverDoThis
{EcoModeler generated code here}
#endif
}
}



Now my values will be calculated every time they are read instead of being cached. The "#if NeverDoThis" bit is there so that EcoModeler will always put its auto-generated accessor code within a region that never executes. I could just put a "return" above it, but I don't like those "Unreachable code detected" warnings!

2007-09-22

ECO pages updated

I've just spent a few hours updating the information pages about ECO on www.capableobjects.com

There's still plenty to do with the content of the site, but at least now there is something to read about ECO IV.

2007-09-11

I hate Camtasia!

I recorded about 2 hours of video, pausing at irrelevant points to bring the time down to about 1.5 hours. I noticed that the audio was out of sync with the video, so I scrapped it and started again.

Then I recorded the same video again costing me another 2 hours of my life. I started to cut out coughs and "erm"'s when I realised the audio was out of sync again. Suspecting the Cut feature wasn't so good I reverted to a backup of the recording that I had luckily made in advance. Unfortunately it seems that at some point during the video the audio suddenly goes out of sync AGAIN! This is a completely unedited recording, so Camtasia is losing the audio sync for some reason.

I am very annoyed! Now I am going to have to render it to an AVI, use SoundForge to fix the sync, and then go on from there. What a waste of life, I am so disappointed!

2007-09-10

Mr thicko thicky thickpants

Well, I feel stupid. Worse than that, I generally feel very thick. Especially yesterday!

So, what happened yesterday? I went to Bletchley Park. What a brilliant place! Walking around what was for approximately 50 years one of the biggest secrets of WWII was really quite strange. The stuff these people did was simply amazing!

One guy managed to figure out the inner workings of a machine none of them had ever seen just by looking at to *almost* identical messages enciphered using the same machine configuration. The second message was 5 characters shorter than the first because the operator repeated the message but decided to abbreviate some of the words to save some time. This was all they needed. Not only was the functionality of the machine divined but what seems to be the world's first (semi) programmable computer was then designed + built to decipher messages received by wireless and then transcribed to punch holes. This thing has a optical reader that works at 5,000 chars per second.

The mathematics involved in working this sort of stuff out must have been quite brain numbing. I left feeling quite depressed with myself but it was still a great experience. Standing next to a Bombe machine (deciphered enigma messages) was brilliant!