Not exactly technology related, but I thought a little more promotion wouldn't go amiss. Since leaving the UK, my brother became a member of a band, Broken Records and I've never yet managed to see them live which is a real shame. They have recently been signed by 4AD and are currently recording their first album which is due for release on 1st June 2009. Good luck lads!
Oh, by the way, they aren't physically coming to New Zealand, just via my blog... Shame, I think it would be a good idea! :)
Partly for my own reference, but also as a shameless plug, here are some of their website links:
YouTube
Facebook Group
MySpace
Here are some videos that are worth watching too:
Broken Records Studio Video Diary - behind the scenes of their album recording:
Official promo for 'Lies' - the 3rd single from Scottish band, Broken Records
A Channel4 review:
Wednesday, 18 March 2009
Broken Records coming to New Zealand...
Posted by Duncan Smith at 8:33 pm 0 comments
Sunday, 1 February 2009
Using language features for readability and understandability
Whilst pairing recently, we came across a situation that I believed was best solved using LINQ. I've not used LINQ much other than reading about it in blogs so it was an opportunity to see what it was all about. In the end, we managed to solve the problem very nicely with very few lines of code. As we continued programming, yet another opportunity arose where LINQ could have solved the problem but instead we chose to write a foreach statement and this made me stop and think about language syntax in general. Why do we chose to use a certain syntax over another? Is it readability? Is it understandability? It is about knowledge? This post explores a few thoughts around this topic.
I can think of a few reasons that might affect why a developer would chose to use a certain syntax:
- readability
- understandability
- fewest lines of code
- existing knowledge of the syntax
- they only know one way to solve the problem
- technical constraint (platform, deployment, etc)
These are just a few choices of the top of my head and I'll examine the readability and understandability first. These two terms are very closely related but they do have distinct differences. I'm not going to discuss them here, but you can read further on Wikipedia on readability and understandability. Suffice to say that the choice of syntax can enhance both these concepts. Let's look at an example:
public string Name
{
get
{
if (name == null)
return "No name";
return name;
}
}
public string Name
{
get { return name ?? "No name"; }
}
These two property statements are identical in functionality but obviously differ in syntax. However, if you do not understand the '??' operator, you will be at a loss for the second statement. However, if you did understand the operator, which of the statements has a higher readability index? I've come round to thinking that they are both readable but one could argue that the first one is more understandable because it uses an explanatory if statement. However, the '??' operator explains the same thing albeit that you need knowledge of the operator to understand its function. Further, you could also argue that the second implementation is more readable because it is only one line of code to read.
Let's look at another example this time using LINQ:
public IList<Customer> GetCustomers(string startsWith)
{
IList<Customer> customersStaringWith = new List<Customer>();
foreach (Customer customer in customers)
{
if (customer.Name.StartsWith(startsWith))
{
customersStaringWith.Add(customer);
}
}
return customersStaringWith;
}
public IList<Customer> GetCustomersLinq(string startsWith)
{
var selectedCustomers =
from customer in customers
where customer.Name.StartsWith(startsWith)
select customer;
return new List<Customer>(selectedCustomers);
}
Again, these two methods return the same result but which one is more readable?
Drawing a conclusion from this is quite difficult as readability and understandability are generally opinionated views. However, what I find interesting is that there are some language syntaxes that are adopted readily whilst others are left behind. Take generics, for example. I don't know any developer that doesn't use generics if they are using .NET Framework 2.0 or above. What is it about the syntax that attracts its adoption? Are developers becoming lazy about learning new syntaxes because they can still accomplish their goals using "standard" syntax? Does using a more recent syntax (Linq, Lambda) reflect on the developer's skill or is it just demonstrating knowledge?
So that I'm not left behind, I'm trying to use these new syntaxes where I get a chance as I believe that the more you use them, the more readable they become - to you. Sometimes, developers fear new syntaxes because they don't understand them well enough to use them effectively and therefore they write them off if they can accomplish the same result in another way. If a new syntax makes for more concise code and it doesn't impair its readability, then I believe it is the right choice. One way to expose yourself to various syntaxes (and code styles) is to take part in an open source project and explore the source code.
I've only scratched the surface in this post about readability and understandability but the concepts of each are extremely important to grasp in order to write good code, IMHO.
Posted by Duncan Smith at 10:02 pm 0 comments
Labels: .NET Framework, C#, Development
Tuesday, 15 July 2008
Creating a custom dictionary for code analysis in VS2008
There seems to be a few posts out there asking where to put a custom dictionary to be used by FxCop (code analysis). In Visual Studio 2008, you can add a dictionary xml file to the solution and then tell the solution to use this as the dictionary for FxCop. Here's how.
Create your dictionary file
Add a new XML file to your project or solution and call it what you want. It doesn't need to be called CustomDictionary.xml.
The dictionary file must follow the correct schema, but unfortunately, there does not appear to be an .xsd schema file available (that I can find). As a starting point, copy the XML from the CustomDictionary.xml that comes with FxCop which is in the default FxCop install directory which on my machine is C:\Program Files\Microsoft Visual Studio 9.0\Team Tools\Static Analysis Tools\FxCop\CustomDictionary.xml. You can then edit this file to include your own words. However, the schema is pretty simple:
Making FxCop use your dictionary
In the properties for the XML file you've created (right-click, properties), change the Build Action to 'CodeAnalysisDictionary'.
Recompile your project and FxCop should no longer complain about those words. If you examine the build output window, Visual Studio makes a call to FxCop.exe with a whole load of parameters. Setting the build action property of the xml file to CodeAnalysisDictionary, makes VS include the switch /dictionary:"
You can also just amened the CustomDictionaryl.xml file in the FxCop default installation directory but this obviously only takes effect on that machine. I like being able to check this dictionary file into source control so that other team members can benefit from it and this also includes the build server.
Reusing the dictionary across assemblies
Another common situation is that you have more than one assembly and you want to share the same dictionary across them. One way of doing this is to add your dictionary file to the solution rather than a specific project. Then, add an existing item to your project, browse to the dictionary file in your solution, and select add as link. This add the dictionary file to your project and makes the link act like a shortcut to the dictionary file in your solution. This means you only physically create one dictionary file which is then easily shared across all your assemblies. Remember, you must still set the build action property on the link file in order for it to be recognised as a code analysis dictionary.
Note: You don't actually need to add the dictionary.xml file to the solution, but it obviously must be checked into your source control system and it should be referenced relatively, not absolutely.
The reason
In most projects I've seen, the code analysis rule CA1704 - Identifiers should be spelled correctly is all too easily ignored by adding a rule to the global suppression file. Personally, I don't like this because I think the global suppression file should not be used as a custom dictionary, especially when there is an alternative. The custom dictionary method is much more portable across projects and it preserves the separation of spelling against genuine code analysis errors.
Posted by Duncan Smith at 1:00 pm 5 comments
Labels: .NET Framework, Development, Visual Studio
Wednesday, 23 April 2008
Standup meetings: Keeping them useful
Every morning, we religiously hold a stand-up meeting to share information around the team - or at least, that is what's meant to happen. Over time, I've noticed that the whole idea of the meeting has been lost and people now attend the meeting because that's what they did yesterday and so it will go on until someone tells them to stop. The stand-up meeting is a technique taken from the Extreme Programming model and I believe it works effectively if you use it correctly.
A stand-up meeting every morning is used to communicate problems, solutions, and promote team focus.
So what does this mean? It means, you have to come to the meeting having prepared a synopsis of what you achieved yesterday focusing on the problems and solutions only. Don't talk about anything else. We only want to hear successes or failures and not all about your daily churn. Remember the audience that you are talking to - developers, testers, PMs, BAs, etc. They all have different interests but as a whole, they all must come together to ensure communication is effective across the team. This is the whole point of the meeting and everyone who speaks should bear this in mind and focus their content to suit the audience.
As a reference, here are some things I believe are not worth mentioning:
- Daily churn - by this I mean we don't want to hear that you fixed a few bugs, added a comment to the order class and corrected a few spelling errors. This is not helpful information and doesn't affect anyone else apart from you. If you do fix a few bugs, say what they were and why they will help other people.
- How you are tracking against your estimates is not productive on a daily basis because it's too granular. Project teams should also hold a weekly meeting that is more appropriate for this type of information. By all means highlight glaring errors in estimates, but don't talk about why you ran over by an hour on your last story card.
- Anything that is implementation specific - remember your audience, save geek-speak for developers.
- Any problems you are having that are not related directly to the project you are working on.
- Solutions and successes. For example, we've worked out a more efficient way of loading information from the database. Or we have changed the structure of the build file making it easier to maintain and it has reduced the build time. People want to hear about what you've been doing and if anything you have done can help them in the future.
- Problems - this means areas of the system that are causing longer development times or are very difficult to maintain. If you don't understand what or how you are meant to do something, raise this and identify someone who can help. If you sit on your own and never mention your problems, no one will know to offer help.
- Milestones or notable achievements - everyone likes to celebrate.
Finally, remember the rationale behind the meeting and why stand-up meetings are part of the XP methodology. As a team, we want to be continuously improving and each member of the team should be making suggestions to ensure this happens. The stand-up meeting is a forum for everyone to discuss their daily findings and making sure that, as a team, we solve those problems. Also remember that a stand-up meeting is not an excuse to stop talking during the rest of the day. It's more likely that you will talk to people in a similar role during the day and this should always continue, but use the stand-up meetings to bring the roles together and to form a team that communicates information effectively.
Posted by Duncan Smith at 1:06 pm 1 comments
Labels: Development
Tuesday, 15 January 2008
Team Foundation Sidekicks V2 Released
Attrice Corporation released Sidekicks V2 on 7th January.
The version 2.0 of Team Foundation Sidekicks application provides all features available in previously released version 1.3.3, as well as new Code Review Sidekick. Significant number of bug fixes was also incorporated in that release; in addition, Team Foundation Sidekicks application now supports Team Foundation Server 2008.This release also deprecates Team Foundation Sidekick Visual Studio add-in; all features previously available in add-in are now part of Visual Studio Integration Package (both for VS 2005 and 2008) which is in turn part of Team Foundation Sidekicks 2.0; new Code Review Sidekick is available as part of Visual Studio package as well.Team Foundation Sidekicks application provides convenient GUI for a wide range of administrative and advanced TFS version control tasks. The version 2.0 stand-alone application includes Workspace Sidekick, Status Sidekick, History Sidekick, Label Sidekick, Shelveset Sidekick and new Code Review Sidekick. Team Foundation Sidekicks integration package for Visual Studio 2005/2008 includes Code Review Sidekick, source control items search, dynamic history and build types editing features.
Download from here
Posted by Duncan Smith at 2:48 pm 0 comments
Monday, 26 November 2007
Too much Resharper...
You know you've been using Resharper too much when you press F12 in a Word document expecting to be taken to the next spelling error! :)
However, now I think of it, it would be a good thing.
Posted by Duncan Smith at 8:03 am 0 comments
Friday, 2 November 2007
Mingle 1.1 Released
ThoughtWorks Studios have now released Mingle 1.1.
The new changes are documented here. There is post installation documentation here which might be useful when learning about the new card types and how to start using them.
A word of warning - Once you installed the new version and launched the website, the installation says "...this could take a very long time". They weren't joking! It took several hours on my machine. I've no idea how long it actually took because I had to leave it running all night. However, it did successfully upgrade in the end. The strange thing was that during the upgrade process, the CPU is hardly used. What was it doing?!
Not had a chance to use the new features yet but from the documentation they look encouraging. Nice work ThoughtWorks.
Download Mingle R1.1
Posted by Duncan Smith at 8:20 am 2 comments