::::: : the wood : davidrobins.net

A LINQ to the future

News, Bad Drivers, Technical ·Thursday April 10, 2008 @ 22:08 EDT (link)

20080402: Morning, 0930: bad driver: WA-520 on-ramp; WA 298 WGN silver or gunmetal Volvo XC90 SUV driven by some wasted bint who either didn't see me or didn't care failed to merge (i.e. tried to ram me from the merge lane); I really didn't want to play chicken with a drunkenly oblivious SUV driver.

20080401: Took Monday/Tuesday as vacation; haven't even looked at my work email, much less logged in, since Friday. We went to Bothell and bought Honey's books for the next quarter; went to Costco, got groceries and Battlestar Galactica season 1.

20080402: New project at work: matching up deviation bugs to specific changes within clauses. Speaking of clauses, the OpenXML specification is now an ISO standard; sigh of relief heard around the building (or not; if it wasn't a standard, we'd have a lot less work to do).

20080404: Argh, LINQ (Language INtegrated Query). In many ways very cool, but why do I need to set a primary key on everything (or at least everything that's a foreign key) for associations (relationships) to work? I've been absorbing all the available C# and LINQ documentation on the web, but I also put a hold on all the relevant MS Library books I could find.

The system library designers have really thought a lot of things through, such as the DrawItemEventArgs being a class with methods than can handle most of the typical owner draw requirements; compare how painful owner draw controls can be in Win32. And then there's LINQ: it's like SQL in your code:
    // attributes copy their parents' workflow bugs (for filtering)
    bgw.ReportProgress(0, "Assuming parent element workflow for attributes...");
    var qAttrDev = from dev in m_pldev
        join attr in m_ecmadc.Attributes on dev.docID equals attr.docIDattribute
        where (DEVT)dev.type == DEVT.Attr && m_mpWkf.ContainsKey(attr.docID.ToString())
        select new { docID = dev.docID.ToString(), docIDparent = attr.docID.ToString() };
    foreach (var monkey in qAttrDev)
        m_mpWkf.AutoVivify(monkey.docID).AddRange(m_mpWkf[monkey.docIDparent]);
(demonstrating integrated queries (select ...), inline anonymous types (new { ... }), type inference (var), and
    public static class Extensions
    {
        public static U AutoVivify<T, U>(this Dictionary<T, U> mptu, T t)
        {
            if (!mptu.ContainsKey(t))
                mptu.Add(t, (U)typeof(U).GetConstructor(new Type[0]).Invoke(null));
            return mptu[t];
        }
    }
which creates the AutoVivify Dictionary class extension member used in the first block: using [] throws an exception if a dictionary key doesn't exist; AutoVivify is a handy extension to create and return a new object of the value type if the key doesn't exist, or to return the existing value if it does (name stolen from perl).

Admittedly, these are things perl has had for ages, but I think C# with the Visual Studio IDE has the "whole package"; auto-completion is very handy (and is actually is intelligent, where it sometimes isn't so much with C++), it's a VM-compiled language with decent speed, creating and using libraries (assemblies) in the UI is very nice (no linker hassles), tables can be dragged straight from the SQL Server client, etc. Its delegates, especially with the => syntax, are as good as perl's closures, and LINQ has some of the convenience of DBI (cp. DBIx::Class, which appears to be somewhat more powerful, but doesn't have a pretty GUI).

Changed thumbnail sizes (numbers are largest dimension): old 120 is now 200, 640 is now 800, retroactive to the photos from beginning of the year. That required updates in a few places: my photo import scripts, journal module, and the photo details display page (what you see when you click on a thumbnail).

20080405: Wee hours of the morning (got to sleep at 0715): added support for journal topics (look under the title to the left of the date; old ones default to News); note: first non default—Technical—back-added for Zune sucks entry). Added in the entry tools, to support the recently created database tables, via the pH::Journal module; finally updated render. The effect is pretty subtle now; I may break it out further e.g. by color coding topics, or break out technical or politics into separate pages (URLs). This is mainly for fun, but if I ever decide to write more consistently on in an area, I can easily break it out into a page without requiring people to wade through the minutiae of my life :).

20080405: Did taxes in the afternoon, took about an hour. Just need to photocopy them and then we can send them out.

20080406: Doctor Who (season 4) marathon to catch up (downloaded 05.01 yesterday). Finished High Crimes and Misdemeanors: The Case Against Bill Clinton (Coulter). Before I read it—the last of a series of her books I've been reading—I had considered not reading it at all; Bill was old news (although he has been managing to make an ass of himself on Hillary's campaign), and wasn't impeached. As I read the book, my opinions changed dramatically: first, I learned that he was impeached (just not removed from office), agreed that he certainly should have been (to paraphrase the book, he got away with things Nixon was impeached for just thinking about doing), for divers sins ranging from the well-publicized Lewinsky/Flowers/Jones/etc. womanizing, to perjury and suborning same, misappropriation of funds, bribery, and treason; after the conclusion I'd have joined a firing squad with him at the business end.

At about 0400: We're finished season 3 of Doctor Who and on to the Christmas special, Voyage of the Damned; after that, the new one, Partners in Crime Had a strange kernel error trying to open the file from the Myth box (possibly due to the big upgrade from the 30th):
smb_proc_readX_data: offset is larger than SMB_READX_MAX_PAD or negative!
smb_proc_readX_data: -59 > 64 || -59 < 0
smb_add_request: request [ffff8100092d3e00, mid=1208] timed out!
Searched for it, found a few mentions that using CIFS instead of SMB will fix it; built and installed the CIFS module, worked like a charm. Looks like SMB is old and busted and not getting bug fixes, and CIFS is the new hotness. Note to self: build CIFS into the kernel before next reboot!

20080408: Reading Introducing Microsoft LINQ (Pialorsi and Russo) and False Impression (Archer).
20080409: Finished both books. PopulateDeviations, AssociateDeviations tools first version ready.

20080410: Taxes photocopied (for our records, in case the IRS doesn't get them for some reason). Finished GRE quantitative (30/30) section; started and finished Anthem (Rand). Salient quotes to come as part of a future political diatribe.

Learning much more about SQL Server. It, C#, LINQ, all good resume fodder (and true expert level, unlike so many that are wildly overinflated… memories from interviewing candidates at Hilton come to mind). Started Atlas Shrugged, the only one of Rand's fiction books I haven't read yet.

DVDs finished: Star Wars Trilogy, The Riddick Trilogy, Æon Flux.