A sort of sequel to the Manifesto for Agile Software Development, I am proud to be a signee of the Manifesto for Software Craftsmanship:
As aspiring Software Craftsmen we are raising the bar of professional software development by practicing it and helping others learn the craft. Through this work we have come to value:
Not only working software, but also well-crafted software
Not only responding to change, but also steadily adding value
Not only individuals and interactions, but also a community of professionals
Not only customer collaboration, but also productive partnerships
That is, in pursuit of the items on the left we have found the items on the right to be indispensable.
© 2009, the undersigned.
this statement may be freely copied in any form,
but only in its entirety through this notice.
Software quality is of huge importance to me. I have always believed that if you are going to do something, it is worth doing right. I believe that quality is an end unto itself, but I also believe that as a side-effect of quality, tremendous business value can be realized.
If you are a software developer that takes pride in the things you create, then I urge you to sign the manifesto.
At the ALT.NET Seattle conference, I went to a session by Nate Kohari on the awesomeness of the yield return keyword in .NET and how you can use it for all kinds of fancy stuff.
In the true spirit of over-engineering a solution, I have created this little property in one of my spec base classes:
1: protected IEnumerable<User> DatabaseUserList
2: {
3: get
4: {
5: while (true) yield return CreateUserInDatabase();
6: }
7: }
8:
9: protected User CreateUserInDatabase()
10: {
11: var user = new UserBuilder().Build();
12: Repository<User>.Save(user);
13:
14: Flush();
15:
16: return user;
17: }
We create what would be an infinite loop which creates Users over and over until the system runs out of memory, but since we’re using yield return, each user will only be created as we iterate over the list. Sexy.
Infinite data structures are a pretty common thing in functionaly programming languages with lazy evaluation. It wasn’t until this past weekend that I realized you could do the same thing in C#.
And using the delayed execution magic of yield return and our good friend LINQ, we can do things like:
1: // Give me an IEnumerable<User> with 5 users in it.
2: var users = DatabaseUserList.Take(5);
3:
4: // Give me 1 user
5: var user = DatabaseUserList.First();
6:
7: // Force list creation, populates DB w/ 10 Users
8: DatabaseUserList.Take(10).ToList();
So this will create users, stick them in the database, flush the database, all lazily as I iterate over a list of users. Is this a good idea? Probably not! But it’s hella cool.
This is the tool I reach for anytime I need to pull data out of XML’s cold bird-like claws.
It let’s you interactively write XPath queries against an XML document. It’s simple. It works well. It’s got syntax highlighting.
Basically, it’s the cat’s meow.