Friday, June 29, 2007

Be Positive

No, I don't mean in a cheesy Disney way. I mean in a nerdy boolean logic way. I'm not sure where I picked up this rule of thumb, but one particularly subtle bit of .NET developer guidance I've started to try to follow is to keep booleans positive. For example: if (myPerson.IsActive) ... //"if the person is active". is easier to think through than: if (! myPerson.IsInactive) ... //"if the person is not inactive". At first pass, this seems nitpicky and maybe even arbitrary. Doesn't this rule just make it longer to test for a negative? if (! myPerson.IsActive) ... But the point isn't so much the amount of code, as it is the the double-negative "not inactive", which burns a few more brain cells to get. An extension of this is when branching: if (myPerson.IsActive) doSomething(); else doSomethingElse(); is better than if (!myPerson.IsActive) doSomethingElse; else doSomething(); Again, the reason isn't so much for the one if..then..else, as it is for the consistency and readability of code as a whole. Anyway, it's helped me =)

Wednesday, June 20, 2007

Spell Check for VS2005

I have horrible spelling, and I know it's crept into some of my applications. FxCop is good for catching it in code, but doesn't help you when it comes to markup inside web applications. I guess I'm a little late finding it, but Mikhail has a pretty good stab at providing this functionality via his Html Spell Check Add In for VS 2005. It does have a couple minor drawbacks. You must run the tool manually each time you want to spell check a file- none of this fancy-pants spell check in the background. (He does have a macro to check all files at once). You also can't add words via the add in- you have to go into Office and add it from there, since it uses Office's dictionary. Those aside, it works as advertised and is something I'll be using frequently. Thanks Mikhail!

Wednesday, June 13, 2007

Windows Presentation Foundation Unleashed

I promised myself I wouldn't buy a Windows Presentation Foundation book until it was fully baked into Visual Studio - with a real designer and freedom from angle-brackets. I know how I am - I was mutzing around with DataGrams before they became DataSets, and ObjectSpaces before they became, well, nothing. I'm an early adopter, and sometimes that's a Bad Thing when it comes to real-world projects and timelines. But then Surface came out, and I just couldn't wait. I downloaded Expression Blend May 2 Preview and on Scott Guthrie's recommendation, bought Windows Presentation Foundation Unleashed and Essential Windows Presentation Foundation. The short review: WPF Unleashed rocks, get it. Essential WPF is decent, but not as good as Unleashed. The longer version: Unleashed is full color- including the code samples- and this makes it much more readable. It does a good job balancing samples and content, and explaining why things in WPF work the way they do. I read Essential WPF second, and so maybe had higher expectations. I do like this Microsoft Development series (Framework Design Guidelines is a must-read for all .NET developers), but this just paled next to Unleashed, and didn't really add or explain much more. The one criticism I have for both books is that I'd like to see more of the whiz-bang examples that makes WPF shine. Unleashed includes a sample Photo Browser app that comes close, but still lacks the 'Wow' that Surface and Silverlight demos are bringing. Some of that is a matter of design principals that fall out of the scope of a technical overview, but this raises my main fear with WPF. Putting this sort of thing in the hands of developers will often lead to trouble. I still cringe when I have to install a video card CD, since I know they've come up with their own goofy UI that will be slower and uglier than a plain WinForms UI. Some effort in these early books to urge restraint and introduce usability and design concerns could help some of us early adopters.

Thursday, June 7, 2007

DanielRoot.com - Take 3

This is about the 3rd or 4th makeover for this site, so I've done it enough to know it's probably not the last. Things are a little different this time around- this will be primarily a .NET development blog (translation: nerd stuff), though I'll no doubt sneak in a few fishing pictures and such from time to time.