NAnt and LINQ - namespace error
I was getting this error when using a NAnt script to build a project I created in Visual Studio 2008. Turns out to be related to which .NET Framework is targeted, in this case.
Aside: If you are not using NAnt, and you're getting this error when you try to build, then make sure your project has a reference to the System.Core assembly. But if you use the defaults in Visual Studio 2008, then you already have this reference. My project would build through Visual Studio, but not through my NAnt script.
Here's the cause. I thought I should use the latest stable release, instead of the latest beta, so I downloaded NAnt 0.85. It supports multiple frameworks, and by default it targets the framework in use. You can point it to another using the -t command-line argument.
But NAnt 0.85 is aware of frameworks only up to 2.0. For LINQ, you need 3.5, and therefore you need NAnt 0.86 (in beta at the time of this writing). I kept 0.85 just in case, so my NAnt folder contains a folder for each version; they co-exist. I just changed the path in my nant.bat file to point it to 0.86-beta. And voilà.
Hope this helps. Yay, automated builds!
Pretty code: Skeptical of elses
Some examples...
Testing a boolean to return a boolean
if (x == true)
{
return true;
}
else
{
return false;
}
becomes
return x;
If you need to swap those,
return !x;
That's a pattern. Recall that comparison operators (less than, greater than, equal to) return a boolean. So this also applies here:
if (myPropertyToCheck == someValue)
{
return true;
}
else
{
return false;
}
becomes
return myPropertyToCheck == someValue;
Guard clauses
You can use a guard clause when you are testing if it is safe to do something, and if not, you want to exit.
if (safeToDoThis)
{
DoThis();
}
else
{
return;
}
becomes
if (!safeToDoThis) return;
DoThis();
When the DoThis() is rather involved, guard clauses greatly help the readability for your future teammates (even when that's you). Step 1, check if we're in an okay state, and if not, just get out of there. This saves you from the Hunt The Else game (although, if that matching else is that hard to find, you could break up your method into smaller pieces with more specific responsibilities).
Comparisons
Compare() and CompareTo() methods need to return -1, 1, or 0. It's handy that these are integers, because now you can harness the Power of Arithmetic to do your bidding. Also when you are comparing your own classes, you often want to compare a property that is a value type or a string. Those already have their own CompareTo() methods, which you can borrow.
Say you want to sort your children by their ages. You don't need
if (child1.age < child2.age)
{
return -1;
}
else if...
(Not just an if/else, but an if/elseif/else. Aaah!) Use instead:
return child1.Age.CompareTo(child2.Age);
If you want to sort them from oldest to youngest, this is where the arithmetic comes in. To flip a negative 1 into a 1, multiply it by negative 1. Same for flipping positive 1 into a negative 1. And zero, conveniently, doesn't mind being multiplied by anything. So you could say:
return -1 * child1.Age.CompareTo(child2.Age);
You can get it even simpler. Because -(-1) = 1, and -(1) = -1, your Compare() method becomes:
return -child1.Age.CompareTo(child2.Age);
Not only no elses, but also no ifs! Very pretty.
Reducing the number of paths through your code (i.e., reducing cyclomatic complexity) gets it closer to being read like prose. Simpler code has fewer bugs, and your successors who have to read your code will think you are smart and good looking. Keep a healthy mistrust of else statements, and write pretty code.
5 Qualities that Make Social Software Social
Social software intrigues me, as it ushers us further down our path to becoming integrated cyborgs. What creates self-sustaining communities? What causes some corners of digital life to reach critical mass and become essential social outlets, while others wither and wander off? What makes these sites successful?
MySpace and their knockoffs strike me as attempts to meet people in a bar (complete with the assault of unwelcome music when you walk in the door). Flickr (photos) and Folia (gardening) are clubs for people with similar interests. I have fun hanging out in these clubs and enjoy the people I meet there. The first community-builder is: Pull together people with a common interest.
Closely related but slightly different is that hobby-oriented sites give people something to talk about besides themselves. For a while I used LiveJournal to keep in touch with my friends, until I got completely fed up with it. I like people better when I am not privy to their every insecure and narcissistic thought (and they shouldn't be subjected to mine, either). But when I keep up with my friends via Flickr, I see their projects, their trips, their outings and their adventures. Those are excellent conversation-starters. The second community-builder is: Plant conversation seeds, something to talk about or argue about that is outside the realm of psychotherapy.
Something that delighted me about Flickr from the first time I used it is the human-oriented, whimsical language displayed by the software. The site greeted me in a different language each time I logged in—how silly! When they brought their new messaging system online and I received my first message, I said, "Hey! A message!" I clicked on it, and Flickr displayed on the screen, "Hey! A message!" That this "photo management system" would talk to me like a goofy, light-hearted friend charmed me utterly. The third community-builder is: Set the tone; make it a fun place to hang out.
If you've played with Flickr or YouTube or LibraryThing, you've had occasions where you go to look up one little thing, which causes you to stumble onto another thing, which leads you to another thing, and then you look at the clock and find that hours have elapsed, making you wonder if you were abducted by aliens who then wiped your memory. By allowing you to stumble upon content, following tangentially related linkages, these sites invite you to explore. The exploration engages your curiosity and keeps you there for hours. Unexpected discoveries create a feeling of delight. The fourth community-builder is: Enable serendipity.
I have been puzzling over my own site, Invisible City, for years. My husband has posted a free print-and-play board game every month since 2000. We get an encouragingly consistent number of hits. The site has areas for visitors to comment, and yet... hardly anyone does. It's like performing a show every night to a sold-out crowd who never claps. The site is definitely missing something.
Looking again for lessons from Flickr, Folia, and YouTube, I have a theory: Community members need to establish their own identities and create their own contributions. In other words, they need a profile page and a place to post their stuff. Invisible City is more like a gallery than a community, because people can come comment on our content, but they can't display their own. Galleries provide a useful service, so there isn't necessarily anything wrong with Invisible City's format, but it will never become a hip hang-out unless it changes. The fifth community-builder is: Give members the means to showcase their distinct identities.
Meat-market social networking sites aimed at helping singles hook up will always be transitory, passing in and out of popularity like fads. A community-oriented site can grow and blossom into a self-sustaining organism with staying power. Looking at my own habits and preferences as a user, I observe that the following five facets facilitate the formation of communities:
- Provide services and features that pull together people with a common interest.
- Give them something non-narcissistic to talk about.
- Set the tone to create a fun place to hang out.
- Enable exploration and serendipity.
- Give members the means to showcase their distinct identities.
Do you have a fun site that you love to hang out in? What makes it fun and what keeps you coming back?
Past the Summit
Earning the "instigator" lable in my blog masthead, I collaborated with some fellow employees to present the "Agile Summit." Yesterday was the day. It was an internal event, a day of training to give a taste of the concepts—whetting the organization's appetite.
The day was definitely a success, but I am also relieved to be past it. (You need a good waterfall project, with lots of slack, to have the time to plan such a thing.) My product owner and I were also part of the agenda, as a case study of one of the few teams at our company using an agile method. Given only a few minutes to get my message out to 300 people, I chose to focus my talk on collaboration. If people learned only one thing from me yesterday, let it be this:
Talk to each other.
Don't use documents and processes as walls to hide behind. Don't look to Agile to be new wallpaper for those old barriers. Agile is a different mindset, and tenet number one is collaboration. Break down barriers and get rid of gate keepers. Here are some of the compelling benefits we've experienced.
Between the business and developers:
- We're able to react to changes (or new information) in the business process, and we're always working on the highest priority features.
- Prototypes—or, really, quick shells of working code—clarify requirements. It's easier to communicate what you want when you have something to look at.
- Developers can understand the why of what they are building, which lets them build the right thing.
- As the business gives feedback and sees that feedback incorporated into the code, they get more engaged and give more feedback. It's worth their bother.
Between the testers and the business:
- Testers are able to understand the business reasons and user goals.
- Testers will ask questions from a user perspective ("Wouldn't the user want to do this?"), which makes a better product.
- Here's a quote from one of our India-based testers, when asked about the advantage of our project's collaborative model: "Everyone in the team has the freedom to ask questions and concerns to the Business." Freedom. Right on.
Between the testers and the developers:
- This code is more tested, period, than on any of my past projects.
- Developers get feedback the very next day on code they have just written.
- Testers are aware of changes in requirements and logic because they are attending the stand-up calls. No need for change requests and updating specification docs.
- Visibility (in the form of the burndown chart) gives us a real, honest feel for where we are in the project timeline. You can look at it and really know whether we're on time or not.
This collaboration makes us successful, and it makes the work more fun. I mean, which would you rather do: talk to a teammate or fill out a 20-page template?
Dictionary as DropDownList Data Source
MyList.DataSource = myListOptions;
MyList.DataTextField = "Value";
MyList.DataValueField = "Key";
MyList.DataBind();
It took me some rummaging to realize that you use the actual strings "Value" and "Key," so I hope this post comes in handy for someone else in the future (even if it's me).
Scrum of Scrums
Early on, our strategy was to organize ourselves into two teams, and have the Austin-based team work on feature A while the Bangalore-based team worked on feature B. That way, we could reduce the impact of our globe-spanning timezones. (There are no normal working hours that overlap for either group. 11.5-hours difference.) We would stay out of each others' way and hardly need to talk at all.
...Hardly need to talk at all? Yeah, that should have caught my attention right away.
But we do learn—this is why we have retrospectives. Exceeding any conference-call discomfort was the pain of not knowing what our teammates were doing, not being involved in additions to our code, not collaborating on a shared, emergent design. So we set both groups to work on the same feature, and scheduled more conversations.
We have two conference calls a week, one in the morning, one at night. Morning-aligned people take the early one; night owls attend the late one. The calls are just for developers, to talk shop. Some of our topics include:
- What we've done so far and what we're doing next;
- How we'll structure our database tables;
- The business domain;
- Suggestions for improving the code.
I've started to enjoy these calls. Not only are they useful (essential, even) for building a coherent application, they are forming the social glue that allows us to collaborate and argue about the design, pulling us together into one effective team.
Presenting to Managers
Your audience is not dumb; they are busy.
There's a common "wisdom" that we need to dumb-down presentations to managers, but this is a hindrance to your message.
No, instead, imagine you are really busy, and you have a lot of demands on your time and, more importantly, your attention. In that mindset, what information do you need, and presented in what order, so that you can make a decision?
As technical people, we like puzzles. We like climbing over multiple steps to discover an answer. We are at times prone to structuring our presentations this way, too: Here's a neat problem, and here are all of the things I tried before finding an answer.
This is a waste of time.
Professor Tufte's argument architecture is this:
- Problem
- Relevance (why it is relevant)
- Solution
Your audience is smart, but busy.
My Kind of Cleaning
First, think through the whole scenario and collect the gear you will need. Realizing you are one biner short when you are up in the air is too darn late. I needed two slings of webbing, each with its own locking-gate carabiner, plus an extra biner. For each sling, I used a girth hitch to attach one end to the front of my harness, then clipped the loose end with a biner into a gear loop at my hip. I hung the spare biner in a gear loop, too.
Next, you climb on top-rope back up to the anchor, and ask your belayer to "take" (take your weight; hold your rope locked off). You clip each sling into a hanger, to set up your personal safety system, and screw shut the locking gates of the carabiners. At this point, you should be held to the rock by your slings and not depending on the rope. Test this by asking for some slack, and noting that, as the rope goes slack, your slings become taut and bear your weight. Then you can ask your belayer to take you "off belay."
Now that you're set to hang out here all day, tie a backup knot to make sure you don't lose that dang rope: Grab a bight of rope and tie a quick knot and clip it into the spare carabiner. Because you're about to do the exact opposite of what your frightened little monkey brain would want you to do—you're going to untie the rope from your harness. And if you drop it, you will get to hang out here all day.
So, yes, untie the knot. The umbilical figure 8 from which you so often hang your precious hide. Untie it.
Remove the rope from the quickdraws and run it through the bottom links of the chains. We use the chains for lowering from the final climb out of necessity, but avoid using them all the time in order to minimize the erosion we subject them to. Retie your figure 8, untie the keeper knot, and retrieve your quickdraws.
Hoist yourself up a bit and ask your belayer to take, so that you can confirm that you are back on belay and the rope will hold your weight. Unhook your personal safety slings and clip them back to your gear loops to keep them out of the way. You are ready to be lowered to terra firma.
In addition to being a MYST-like brain teaser, I found route cleaning to be a good barometer of my mental state. Late in the afternoon, I'm hanging from the slings, and I think, "Okay, I have no idea what to do next... Must be time for dinner."
And it was. So we three girls drove back into town and ate three cheeseburgers, and they were very, very good.
Climbing Logistics
Goal: Before your climb, a teammate lead-climbed the route and set up an anchor for you at the top, using some of your equipment. Now you need to climb up there, retrieve your equipment, and get safely back down.
Setup: At the top of the sport route, there is an anchor system. This system comprises two hangers, bolted into the rock, and a few links of chain hanging from each hanger. Your lead climber clipped a quickdraw into each hanger, and ran the rope through the bottom carabiners of the quickdraws. (Here's an anchor using a rope instead of two quickdraws.) This allows many climbers to use this rope and anchor while minimizing the wear and erosion on the chains. But you want your quickdraws back.
Constraint: You're 25 or 30 feet in the air. You climbed that high using your own muscle power, and you've been climbing for hours already. You're tired. You don't want to fiddle with ropes and clips and slings while hanging by the tender fingertips of one hand above the rocks and trees below.
Solution: What to do? (Open the spigot to drain the water from the chest, close the spigot, fill the tower with water to make the chest float up...) I'll let you think about it for a bit. Perhaps if you look around, there might be some more gear here at the bottom that you could click on.
The problem-solving challenges is one of my favorite things about this sport. Hanging with great people and the sense of accomplishment are two more. You really make a connection with the woods when you're that close to the rock.
Convincing through Understanding
I had the opportunity last week to talk with a small software company about what's exciting about scrum. My battle scars all come from years in a BDUF (Big Design Up Front) shop, so I was non-plussed to find that this small, smart, co-located group was looking to scrum because they craved more structure. It's an important reminder: Agile methodologies are processes. They're just processes for adapting to change, instead of anticipating and squelching change.
Not everyone in the audience was a fan of scrum. Some were skeptical, or intrigued but full of questions, while others were adamantly opposed. A totally different company from the one I work for, yet the objections were eerily similar:
- Maybe that works for a [big/small] company, but it won't work in our [small/big] company.
- More meetings?!
- We don't have enough resources for [testing/support/pair programming/a Scrum Master who isn't a developer].
- Constant feedback? That's so disruptive. They keep changing their minds. I'll never get anything done if I talk to them every day.
- If you build the architecture as you go, what if you get it wrong?
- When do you create documentation?
- Who prioritizes the requirements? How do you prioritize? How do I get infrastructure and foundation pieces onto the list?
- How do you know if you're on time?
- I prefer my private cubicle. I don't like talking with people all the time. I'd rather be efficient than social.
You can hear the fears behind these objections if you listen openly:
- I know how to do what we do, and you're talking about changing how we do what we do. That's going to make me look less competent.
- I'm stressed about deadlines and my workload, and it sounds like you're increasing my workload.
- I'm constantly harrangued about dates and deadlines, and you're proposing a deadline every [1 to 4] weeks. That sounds like incessant stress.
- My past conversations with my [customer/user/business partner/product owner] have been abusive and dysfunctional. Every time they tell me what they really want, I have to disappoint them because of resource constraints. They have no faith in our estimates of effort or duration. I can't convince them to invest time in supportability, maintainability, or scalability requirements. There's no love here.
- Face it, I'm an introvert. Why do you want to force me to be extroverted?
Once you're hearing what people are really telling you, then you can discuss the underlying concerns. Together, you and your audience can collaborate to clear up those concerns. What was initially a roadblock—a rigid resistance to change—becomes a challenge to be solved together.
I feel like a big cheese monkey for quoting The Seven Habits, but it's elegant and succinct on this point: Seek first to understand, then to be understood.