Punxsutawney Phil, some rodent 2,000 miles from me sees his shadow so we get 6 more weeks of winter. Had he not seen it, winter would only 42 days left. I will have my traditional Groundhog Day dinner of pork sausage.
Thursday, February 02, 2012
Happy Groundhog Day!
Wednesday, January 11, 2012
Less Than Simple Group By LINQ Queries
Lately I have been going through LINQ. Most of it has been review, however I ran across something that I really didn’t understand. That area: Grouping.
Suppose I wanted to write a LINQ query which would do the following:
SELECT a.city, COUNT(*) AS CountI can easily render this into LINQ as follows (LINQPad C# Expression):
FROM authors a
GROUP BY a.city
from a in Authors
group a by a.City into c
select new
{
City = c.Key,
Count = c.Count()
}
When things got just a little bit more complicated, I got lost. Suppose that I wanted to render this query:
SELECT a.au_lname, a.au_fname, a.phone, COUNT(*) AS Count
FROM authors AS a
GROUP BY a.au_lname, a.au_fname, a.phone
I figured out that the Key didn’t need to be a simple type. The type of the Key is determined by the type between by and into in the group clause. So here I create an anonymous type for the key and refer to the properties of Key in the select clause. So I can render it as follows (LINQPad C# Expression):
from a in Authors
group a by new
{
a.Au_lname,
a.Au_fname,
a.Phone
} into c
select new
{
Au_lname = c.Key.Au_lname,
Au_fname = c.Key.Au_fname,
Phone = c.Key.Phone,
Count = c.Count()
}
GroupBy() (the extension method that group .. by is translated into) returns an IQueryable of IGrouping(s), a IGrouping is an IEnumerable with a generic Key property tacked on. Since Key is generic, I can pass in a complex type.
NOTE: I haven’t been able to get it to work with a non-anonymous type In LINQ to SQL.
I didn’t use LINQ grouping in my production code. I don’t know if it is because I didn’t understand it or just didn’t need it. If I really needed it I would think I would have pushed harder and learned it earlier…
Saturday, December 31, 2011
Example of Repetitive Comments
Looking through some old code for a project I’m working on I saw a block of code similar to this:
/// <summary>This code annoys me. Yet I see the problem: the XML comments are just a little too far away from the actual data. I think it would be cool to have tool tips for the parameters described in XML comments. It would have also helped name the parameters better.
/// This is MY method
/// </summary>
/// <param name="intValue">Some Number</param>
/// <param name="stringValue">Some String</param>
/// <returns>An empty string</returns>
public string MyMethod( // Returns An empty string
int intValue, // Some Number
string stringValue) // Some String
{
return string.Empty;
}
Friday, December 16, 2011
Two devices to read a tech book
Last week I bought some technical books from the internet; they were stolen from my front door and I needed them immediately, so I ordered the e-book version. I like e-readers for pure text that is meant to be read in order (novels, histories, etc.), but technical books have diagrams, tables and code samples (“figures”) that may be referenced several pages later. So I decided to try using two devices …
I use the reader for the text and the tablet for the figures. I don’t like to read lots of text on a tablet because it is backlit. I really like reading plain text on a reader; I bought mine this spring and read the Lord of the Rings (+ the Hobbit) on it. I like reading on it better than reading books.
Since the reader doesn’t support zoom, I like to use the tablet to zoom the figures; actually, the image support on the reader is so bad that it would be difficult to read my current book without viewing images on the tablet.
This is not a supported way to read an e-book and will probably never be. Even with the hassle of juggling two devices it is better than the supported way. It would be nice if I could move between figures without shuffling through the text. Some UX designer better than me needs to do something to improve the tech book reading experience.
Thursday, November 17, 2011
My Play
In this week’s This Developers Life, they discussed Play. Not to be out done, I thought I would write about my own play patterns. It was fun to hear about the race car driver and the home manufacturer, I want to hear more. To promote dialog, I am presenting my story.
Improv
Almost 2 years ago, I started taking Improv classes at the Blue Door Theatre in Spokane because I heard about some consultancy in New York City that provided Improv classes to all their consultants. The local NPR station announced the class on their arts calendar and I just said what the F# and I took the class. At that point I had never even seen live Improv.
Like many programmers, I have an Aspergers personality. This serves me well when I am actually doing my core job; for the rest of my life, not so much. Improv gives me a chance to play at being in the world where everyone else lives. It gives me the opportunity to playing at being an extrovert.
Through something we call “Yes, And”, I am learning to accepting the current situation and adapting to the current situation. And I am learning to do it quickly. As a programmer, I like to work carefully and look for the perfect solution; in Improv I just don’t have the time. (The programmer in me is telling me that this blog post isn’t good enough; if it wins, no one else will ever read this.)
Am I taking Improv to become a great actor and become famous? No. My chances of ever performing Improv in public: about 50/50 (based on the fact that most of us underestimate our own talents). Do I really care? Do you take Kung Fu to fight? If memory serves me right, Cane was able to avoid fighting as much as he fought. I have presented at Code Camps 5 times since I started Improv.
Technology
My work project is frozen to the technology that existed when it was started. I like to play with the new stuff. I have Windows 8 installed on my laptop. I am slowing working my way through WPF 4 Unleashed. I am looking into writing for the Android Tablet. No, this is an extension of work.
Music
I have a guitar, a bass and a keyboard that I attempt to use to make sounds with. In the past I found that the guitar to be a great stress reliever. On second thought I haven’t really even touched these things since I started Improv. Since classes don’t start up again until next year, I would take out an instrument and …
Christine
I have a 1982 Supra that I have tried to keep alive for the last dozen or so years. Due to some poor financial decisions on my part, I haven’t done much with her for the past couple of years. My dream is to restore her on YouTube. Yes, her name is a reference to the Stephen King book.
Wednesday, November 09, 2011
Tablets and Open Source Voting Software
Yesterday on NPR, they had a short piece on iPad Voting. I don't like modern voting machines because of the closed nature of their software; very few people know what is going on inside those things.
If I had my way, the voting software would be written as an open source project. The voting machines would be common hardware that could be used in schools after election season. On Election Day morning, representatives from all interested parties would download the source from the project's site, build, run unit tests, install the software and generally verify that the software is correct.
The hardware would probably be tablet computers. Right now the market would be iPad, Android and, coming soon, Windows Metro. I would imagine that each vendor would sponsor voting machine projects that use their hardware. When the local community center would buy tablet computers of some after school program, the quality of its open source voting software may affect the buying decision. You wouldn’t need to buy new hardware every election cycle, schools could go without the iPad for the first week of November (“Hey kids, this is a ‘yellow pad’, we used these in the 20th century”).
Monday, October 31, 2011
Windows 8 and Fear of Change
For Halloween, I will discuss Windows 8 and Metro. I hear lots of fear and loathing in regard to Microsoft’s strategy regarding Windows 8 and the tablet.
I’ve heard horror stories about how we will be forced to throw away all we’ve learned the last 10 years and learn to write apps in HTML5 and JavaScript. Tales that Silverlight is doomed to the bone yard and so on … In short, the technology world changing and all our skills will be null and void. In our next job, we will need to rehearse the phrase: “Do you want fries with that?”
Come on, part of being a developer is dealing with change and uncertainty. In the mid 1990s, we went from DOS and character based computers to the GUI Land of Windows 95. In the early 2000s it was .NET for everyone in Windows Land. And now there are rumors of doom about what Microsoft is up to with Windows 8.
Part of the bargain of working in this business is change; we get to work on the cool new things and we have to work on the cool new things. We spend more time keeping up, learning things we need to be up to date. By choosing what to learn, we are also placing bets on winners and losers. If I study Window 8, I am betting for Microsoft and against Google and Apple. Of course, I could hedge my bet by studying both Window 8 and Android (that would reduce my potential reward.
Windows 8 etc.
Windows 8 (WinRT, Metro, etc.) represents to response to iOS and Android tablets. I don’t know if Windows 8 will preserve the market share that Microsoft has enjoyed with Windows for the past generation. I don’t know if Windows 8 will be a second Vista. It is even possible that this is the beginning of the end of Windows or even Microsoft.
I can’t say that Microsoft is late to the Tablet game. There was the PocketPC that was a small tablet that used a “pen” and there was a tablet version of Windows XP (also used a “pen”). These are pen tablets, the cool new tablets are touch tablets.
Microsoft is taking a different approach than Apple. Apple has two Operating Systems: iOS for tablets and devices and OSX for full blown computers. Microsoft is going with One OS to Rule Them All: Windows 8 will be on desktop and little tablet devices. I suppose WP8 will be Windows 8.
There are as many changes in the other platforms. Change defines our industry. Every change represents risks to all participants. Not changing also represents risks. This is just part of the job.