Fear and Loathing
Gonzo blogging from the Annie Leibovitz of the software development world.
-
Lies TFS Told Me
This morning we suffered an air-conditioner failure in one of the server rooms. As our TFS server was deployed to a server with the words "dev" in it, naturally they thought they could just shut it down. After all, dev means development so it's not critical. I don't blame them however it caused a few issues. This one was shared to me by one of my developers so hopefully it'll help some of you out there in TFS land.
So apparently if the TFS server goes down while you're working on a file Visual Studio will allow you to work on the file locally. Makes sense. However, while editing the file, the server does not know that you have updated the file. Thus, when you reconnect to the server (or in this case the server comes back from the dead) TFS doesn't realize the file has been modified and will not save the changes to the repository when you complete a check-in.
To get TFS to check-in the modified file you must specifically go to each of the modified files and select Check Out for Edit. Then, select None - Allow shared checkout and click the Check Out button from the Check Out dialog that appears. Finally, check-in (commit) the files back to the source repository.
The one other symptom is that your local files are not set to read-only like all other files when you try to update from the repository (Get Latest Version).
Something to watch out for in case your server goes bye-bye in mid-development.
-
A refactoring that escapes me
We had a mini-code review on Friday for one of the projects. This is a standard thing that we're doing, code reviews basically every week taking no more than an hour (and hopefully half an hour once we get into the swing of things). Code reviews are something you do to check the sanity of what someone did. Really. You wrote some code 6 months ago and now is the time to have some fresh eyes looking at it and pointing out stupid things you did.
Like this.
Here's the method from the review:
1: protected virtual bool ValidateStateChangeToActive()
2: {
3: if ((Job.Key == INVALID_VALUE) ||
4: (Category.Key == INVALID_VALUE) ||
5: (StartDate == DateTime.MinValue) ||
6: (EndDate == DateTime.MinValue) ||
7: (Status.Key == INVALID_VALUE) ||
8: (Entity.Key == INVALID_VALUE) ||
9: (String.IsNullOrEmpty(ProjectManagerId.ToString()) || ProjectManagerId == INVALID_VALUE) ||
10: String.IsNullOrEmpty(ClientName) ||
11: String.IsNullOrEmpty(Title))
14: {
15: return false;
16: }
17: return true;
18: }
It's horrible code. It's smelly code. Unfortunately, it's code that I can't think of a better way to refactor? The business rule is that in order for this object (a Project) to become active (a project can be active or inactive) it needs to meet a set of criteria:
- It has to have a valid job number
- It has to have a valid category
- It has to have a valid start and end date (valid being non-null and in DateTime terms this means not DateTime.MinValue)
- It has to have a valid status
- It has to have a valid entity
- It has to have a valid non-empty project manager
- It has to have a client name
- It has to have a title
That's a lot of "has to have" but hey, I don't make up business rules. So now the dilemma is how to refactor this to not be ugly. Or is it really ugly?
The only thing that was I was tossing around in my brain was to use a State pattern to implement active and inactive state, but even with that I still have these validations to deal with when the state transition happens and I'm back at a big if statement. Sure, it could be broken up into smaller if statements, but that's really not doing anything except formatting (and perhaps readability?).
Anyone out there got a better suggestion?
-
Well, that was a short trip
Unfortunately, due an emergency I have to cancel my trip to the MVP Summit. Bummer. A week of frolicking with other MVPs, missing out (again) on Jeff's party (220+ people so you know it just has to be good, or at least crowded), a week of in-depth sessions with Microsoft product teams, and generally having a grand old time. Ah well. There's always 2009.
To my fellow MVPs and plumbers that are having a good time right about now, and the softies I was going to mame with some up close and personal paintball damage, have a great time and feel free to make fun of me or talk about me behind my back. I know you wanna.
In the meantime I guess I'll just blog about SharePoint and whatnot this week seeing that everyone else will be talking about parties and things they can't blog about. Guess I'll be the odd man out. More audience for me, and you know, it is all about me!
-
MVP Summit - Day 0 - Lift off!
And so it begins. Another conference, another series of wordy photo blog entries from my twisted sense of humor over the next week. This week 1700 MVPs are gathering in Seattle/Redmond for our kindof-annual Summit (happens every 18 months or so). This time round big Bill Gates is giving the keynote on Tuesday and there's going to be plenty of fun, networking, and surprises this week so stay tuned.
With that I have all I need. My laptop, a moose, and my passport to prove that I'm not a terrorist.
It's a few hours before I leave for the airport. Stupid me, I decided to go cheap with the flight and pick a stop-over in Vancouver. So a short flight to Vancouver (90 minutes) then a 3 hour lay over, then an hour flight to Seattle. What was I thinking?
For those of you hunting me down, I'll be at Jeff's party tonight as soon as I drop my bags off at the hotel (I touch down at 7 and the party kicks off at the same time). I'll be snapping shots of all your favorite MVPs in various state of debauchery (Rory, this means you!) and posting later tonight. I'm staying at the Grand Hyatt Seattle and will post info about what room you can charge your mini-bar too, etc. later when I can catch a breath.
The week is all NDA content so us MVPs won't be posting much info however last summit we were allowed to talk about something in Office 2007 (the save to PDF) which got nixed anyways. Maybe they'll be something we can post this time round, but I doubt it since the next version of Office/SharePoint is too far off.
My Flickr site will contain all the goodies I snap over the week. We've also created a tag for the SharePoint MVPs to swap photos so Flickr pics should be tagged with mvp07 for the summit. I also have a Flickr set for the summit here which will grow through the week. Expect at least one blog entry a day, but I'll try to squeeze in maybe 2 or 3 with pics as the conference is near our hotels so we can head back to recharge during the day (or night).
So feel free to live vicariously though my blog entries and pics and we'll talk to you later!
-
2007 time zone update, will it be worth it?
March 11 is almost here and the crazy time zone updates are upon us. If you're looking for info on Windows operating system updates, check out the KB article here. Personally I can't follow it. At this point I'm not sure if my XP SP2 box is updated or not? Or if it will update? I'm a pretty techy guy but some things I just don't give a rats ass about, and this is one of them. Normally it just updates but tonight I don't know if it will so I would have to do it manually. Then in 4 weeks when the automatic DST adjustment kicks in, I'll have to manually adjust the time again? (and twice more in October/November). What bothers me is that if Microsoft has the time zone adjustment already in the operating system, why can't they issue an update to handle the new one (or maybe they did, again, not paying attention here).
I've seen so much hype about this and have to wonder is this going to be worth it? I mean, the 3 week adjustment now and 1 week adjustment in October is apparently going to save gobs of cash. Is it? Is there someone going to measure this? Is this even measurable? 6 months from now I'm sure someone will come out and say it is, but how true will it really be. Give me a bunch of stats and I can spin them any way to appear to be value-added. That's what statistics and numbers do. They're the truth but as Obi-wan said, from a certain point of view.
Personally I don't think it's going to save the billions of dollars anyone thinks it will but maybe that's just one geeks opinion.
-
Expand your horizons, get introduced to C# 3.0
Scott Guthrie has an excellent summary post of some key features in .NET 3.0 that's coming in the next release of Visual Studio (codename Orcas). His post is short, sweet, and shows how you do something today and how it can change in the future.
This covers automatic properties, object and collection initializers (all of which I've been really digging in my test environment). Even with mocks, writing test code is that much easier in 3.0 (or is it 3.5 now? I always loose track) and the syntax isn't as cryptic as LINQ (which I'm still wrapping my noggin' around).
Check out Scott's post here to get introduced to the new C# features.
-
Communities need care and feeding
A long time ago in an office far, far, away I started up the SharePointKicks site. It was a bright idea spurned on by the popularity of DotNetKicks. Community driven content like Digg, etc. but focused on SharePoint. The early days I was submitting a lot of entries (mostly my own) and hunting down the choice ones out there written by you. As with any community site it needed something. A community. One that could contribute and nurture and make it grow.
That really hasn't happened.
SharePointKicks is a great site, or can be. Lately it's been pretty barren of new content and it hasn't shared the popularity of it's sister site DotNetKicks. Sure people still post, but I know there are tons of new SharePoint 2007 blog entries that are gems. That's what the kicks site is there for. Pulling those gems out of the quagmire called the net and letting them bubble up to the surface through your "kick" votes. The more popular something is, the higher up the charts it is and there it stays.
It's sad to see a community wither and fade away like this. I'll admit I haven't spent a lot of time lately seeding it myself as I felt the SharePoint community would pick up on the concept and run with it. That's not happening and I'm not sure why. Maybe I'm wrong in my premise that SharePointKicks was a good idea, or maybe everyone is too busy (like I've been) to contribute.
In any case, SharePointKicks will live as long as it's host keeps it alive. Like I said there are people contributing, but it's a trickle compared to the SharePoint content I read each day. If you can, please keep it in mind to contribute somthing (content people, not money). Either your own blog entries or someone elses. Hopefully with your input the site can continue to grow instead of stagnate which it's been doing for a few months now.
Thanks.
-
What's in your OSS box?
Following on the heels of Jeremy Miller and JP, here's a list of my open source tools in my tool chest. My list may be surprising to some.
- Enterprise Libraries. Some people hate 'em and there's people that blast them for being "too big" but it works. Free logging, exception handling (via policies I dictate through an XML file), and other goodies. Version 3.0 adds some business validation framework and even more stuff.
- Composite Application UI Block (CAB). A library that provides a framework for building composite applications. It lets me modularize things and not worry about the plumbing to make things talk to each other (thanks to an easy to use event broker system). It also includes ObjectBuilder to boot which is a framework to build dependency injection systems.
- Smart Client Software Factory. Another framework (and collection of guidance packages) that jumpstarts building Smart Client applications. Basically provides a hunk of code I would normally have to write to locate services, load modules, and generally be a good Smart Client citizen.
- NAnt. Can't stand MSBuild and wouldn't give it the time of day. NAnt is my savior when I need to automate a quick task.
- NUnit. Again, MSTest just dosen't measure up when it comes to integration with my other tools and most everything is written these days with NUnit examples. Okay, so NUnit isn't as powerful as say MbUnit but I just love the classics.
- CruiseControl.NET. The ThoughtWorkers are awesome dudes of power and CC.NET is just plain simple (see my struggle with Team City recently).
- TestDriven.NET. A great tool that I can't live without.
- NCover/NCoverExplorer. I just love firing up TestDriven.NET with covage and seeing 100% in all my code. Where I'm lacking, it points it out easily and I just write a new test to get my coverage up.
- Subversion. I have a local copy of Subversion running so I can just do quick little spikes and maybe file the code away for a rainy day on an external drive.
- TortoiseSVN. And CVS I guess when I have to access CVS repositories out there in internet land. I'm still waiting for a TortoiseTFS.
- RhinoMocks. I started writing mocks last year and haven't looked back since. While it does take some going to set things up, if you start writing mocks and doing TDD with them you'll end up with a better looking system (rather than trying to mock things out after the fact). Rhino is the way to go for mocking IMHO.
- Notepad++. Lots of people have various notepad replacements, but I prefer this puppy.
- WinMerge. Great tool for doing diffs of source code or entire directories.
This is what's in my toolbox today and I use on a daily basis (and there's probably more but I haven't had enough Jolt tonight to bring them out from the depths of my grey matter). I've glossed over and checked out various other tools like NHibernate, Windsor, iBatis, and even Boo but they're not something I use all the time.
While I don't have as many as the boys, I think I have what I need right now. What's surprising looking at the list is that some of my stuff is Microsoft which just flys in the face of any comments from people that "We only use Microsoft" means you *can* use OSS tools even if they're from the evil empire. Even with the MS list of items I use, I'm covered with things like dependency injection and separation of concern although the MS tools don't fare nearly as well as say Windsor or StructureMap, they still do what I need them to.
-
Tuesday Night Downloads
Two downloads I thought I would toss out there for your feed readers to consume.
Visual Studio 2005 Service Pack 1 Update for Windows Vista
During the development of Windows Vista, several key investments were made to vastly improve overall quality, security, and reliability from previous versions of Windows. While we have made tremendous investments in Windows Vista to ensure backwards compatibility, some of the system enhancements, such as User Account Control, changes to the networking stack, and the new graphics model, make Windows Vista behave differently from previous versions of Windows. These investments impact Visual Studio 2005. The Visual Studio 2005 Service Pack 1 Update for Windows Vista addresses areas of Visual Studio impacted by Vista enhancements.
Sandcastle - March 2007 Community Technology Preview (CTP)
Sandcastle produces accurate, MSDN style, comprehensive documentation by reflecting over the source assemblies and optionally integrating XML Documentation Comments. No idea what's changed in this CTP but now that NDoc is dead and buried, like Obi-Wan, this is our only hope.
-
NetTiers gets a Wiki (a real one)
One of my more favorite tools is NetTiers. Calling a template a tool might be a stretch but it's my primary reason for using CodeSmith. NetTiers is basically a set of CodeSmith templates that, when pointed at a database, gives you a nicely separated layered set of .NET projects for accessing your data. Basically an auto-generated data access layer. One class for each table in your schema, one property for each column, methods for stored procs, wrappers for accessing aggregates like getting all records (by primary or foreign keys) and other good stuff. I've used it for my data access layer in a few projects and even used the autogenerated website either as a starter for sites or entire sites where all I needed was a set of pages for data maintenance.
Documentation is always a bear for any tool (free or otherwise) and NetTiers is no different. The templates generate 10,000 lines of code, hundreds of classes (depending on how many tables you have) and it's a lot to take in. The forums they have are good but it's hard to find information (even with search) and information quickly becomes out of date without any care and feeding. Wikis can help (but not solve) that by turning to the community for contributions. I'm a firm believer that it's easier to have 10 monkeys write 10 pages than 1 person writing 100 pages of documentation (and we all know who the monkey is here).
So now the NetTiers team has setup real wiki here just for that purpose. Signup for an account and start contributing if that's your thing. This is an improvement over the previous "wiki" they had setup but that effort wasn't quite optimal. The wiki was closed to the public and only contained a handful of canned pages. In any case, the new one is out in the open and ready to go. So if you're a consumer or contributor (or both like me) check it out!