Tuesday, April 01, 2008

I've been reading Charlie Calvert's blog, and his list of LINQ providers, and watching both the Lightspeed and LLBLGen Pro LINQ beta's with interest.

There's an available product that you can buy - the CHI69 "Computer Human Interface" - I have written a LINQ provider over the API provided within the supplied SDK.

Download the beta LINQ to Spouse provider here.

Connect to the CHI69 device, and read in the environment:

// Open environmental interface
Environment environment = CHIConnector.Connect<Environment>();

Build the representation of the user:

// Open self-representation
Husband me = CHIConnector.Self<Husband>();

The device allows querying the local environment for objects of different types using LINQ: 

// Search all available for a girlfriend
var prospects = CHIConnector.AllAvailable<Girlfriend>();

Girlfriend girlfriend =

(
from prospect in prospects
where
(prospect.Husband ==
null || prospect.MaritalStatus == MaritalStatus.Rocky)
&&
prospect.IsCompatibleWith(me)
select prospect
).First();

Peform some realistic actions with returned objects:

Thread.Sleep(69);

The library exposes a rich interface:

// Test marriage criteria

if (me.Mood == Mood.Romantic &&
    environment.Lighting <=
Lighting.Flattering &&
    girlfriend.Emotions.Contains(
Emotion.Desperate))
{

// Note the downcast. Some functionality will become unavailable
me.Wife = (Wife)girlfriend;

}

So go ahead and test the library and provider. I'm interested in any feedback you can give.

Some notes:

  • Wife inherits from Husband (by definition, the functionality is a superset)
  • Version 69 of the CHI device only allows for monogamous relationships. Due to demand, apparently this requirement will be removed in an upcoming release
  • As an optimisation, some inherited properties are implemented or cached in the class library, rather than querying the real-world object (e.g. wife.IsRight does not require a remote call as the result is deterministic)
  • The default device communication protocol is messy. Using SOAP would clean it up.
  • Setting me.Salary = 0 will throw an OutOfLuck exception, terminating the program.
  • High intensity emotions (e.g. wife.Emotion.Intensity >= Intensity.Danger) result in unpredictible behaviour.
PageofWords.LINQToSpouse.zip (14.36 KB)
Wednesday, April 09, 2008 11:29:09 PM (New Zealand Standard Time, UTC+12:00)
Gee wizz, and there's the rest of us .net folk spending our days writing accounting software and messaging platforms - when we could be modelling much more relevant domains.

while (me.Drink(new Vodka()) {
me.Vision.Blur++;
foreach (Bartenter bartender in (Bar)this.Establishment) {
if (bartender.IsFemale) {
bartender.Rating++;
}
}

Thread.Sleep(Vodka.RecoveryTime);
}
All comments require the approval of the site owner before being displayed.
Name
E-mail
Home page

Comment (HTML not allowed)