Saturday 31 December 2011

A generic repository

Way back in January I said that I was going to post on a generic repository, due to various other diversions during the year I never managed to get around to completing this work but on the last day of the year it is finally all done and to tick off one of my goals here is the post about it.

What’s it all about?

When talking about both Linq to Sql (L2S) and Entity framework (EF) you will frequently hear developers saying that they will be using a repository to encapsulate the ORM interactions, what this means in practice is hiding the actual ORM functions and providing a abstract class or interface you can mock to make it easier to test your applications.

Tuesday 6 December 2011

A S.O.L.I.D data access layer

A while back I had reason to look at one of my assemblies in my “toolbox” which wrapped the System.Data.SqlClient assembly and as often happens when you look at old code you cringe and wonder what you were thinking when you wrote it, so I decided to refactor the code using S.O.L.I.D principles to make the code easier to understand, test, maintain and extend and so ADO.NET DAL was born.

For those of you who follow on me on Twitter you’ll know I spent a long time trying to ensure that the library had 100% code coverage but unfortunately I never made it, one method still eludes me but 99% coverage is pretty good Smile.

Tuesday 29 November 2011

Getting to grips with a Windows Phone 7

Last Wednesday I became the owner of a windows phone 7 (WP7), a HTC Radar to be precise. My current mobile contract had expired and I had been toying with the idea of getting a WP7 for a while.  Unfortunately I was dubious about the platform and didn’t really want to take out a long contract and end up with a phone I didn’t want, and as all my attempts to get a free phone failed I decided to try and buy a SIM free phone. A brand new phone was beyond my budget so I turned to eBay and found a few WP7’s listed and managed to pick up a Htc Radar for about £200 which was a result.

Why a WP7?

I have already been asked why I’d want to buy a WP7 and the simple answer is that I am a .Net developer and I want to do some mobile development, not just on the emulator but to be able to actually deploy to the device for testing and ultimately the market place.  Whilst I’d already got an Android phone (HTC Desire) I was faced with having to find time to learn java or find the money to buy MonoDroid neither of which were likely to happen.

Tuesday 22 November 2011

The resource cannot be found - /Account/Login

I ran into a problem the other day that I could find very little information about so I thought I’d put a blog post together to

a) remind me
b) hopefully help anybody else who runs into this problem.

I picked the obtuse title as it is very close to the ambiguous error message I got and should hopefully help other people find the solution far faster than I did.

Recently I was working on a MVC3 application, it was working well and I wanted to sort out dependencies for our CI server so that we didn’t need to have MVC installed on the server for the code to build and intended to do this by adding bin deployable dependencies.

Wednesday 16 November 2011

What type of team leader are you?

For a lot of developers the team leader position is a coveted one, it is as if when you become team leader the business is acknowledging you and your skills, but unfortunately for a lot of developers that reach this position it is not always what it seems.

From my experience the team leader role will usually fall into one of the 3 following categories:

  1. Team leader as Development manager
  2. “Normal” Team leader
  3. Team leader as technical lead/architect

Lets take a quick look at what each of the categories entails.

Wednesday 2 November 2011

GiveCampUK–one very busy weekend

So the weekend of the 21st of October saw me attending the inaugural Give Camp UK event organised in the main by Paul Stack and Rachel Hawley to provide bespoke software solutions to charities.

The challenge was to be able to create the necessary software during the weekend and if possible get it live for the charities to be able to use.  The event was to start at around 5pm on the Friday night and coding to finish at 12pm on the Sunday when the teams would then present the software they had created to the other teams.

Friday 21st

I travelled into the event with my co-worker Johan Barnard, we had no idea of what we would need to do or what sort of software was needed but we were looking forward to the challenge!

We arrived at UCL just after 4pm and after registering we meet some other developers we knew including our other colleague from Dot Net Solutions, Mark Rendle, and waited for the kick off.

Friday 21 October 2011

GiveCamp–what I hope will happen

So today is the day! GiveCamp is here and the next couple of days are likely to be manic.

I know what the organisers are hoping but seeing some tweets fluttering about I wanted to record what I hope will happen.

So, I hope that:

  • Developers who’ve said they’ll come do come
  • We focus on delivery of software for the charities
  • We don’t just use the latest tech because “we want to” or its cool
  • The charities involved get as much of the functionality in the software as possible
  • I meet new people and meet-up with existing friends/acquaintances
  • Everybody has fun.

Rob Ashton summed it up on twitter nicely saying

“Personally at #givecampuk I'm going to try and avoid doing New Things, I want to Deliver, learning will happen even then of course”

If you’re a reader of this blog and you are going to givecamp if we haven’t met before come up and say hi, will be good to meet you.

Friday 19 August 2011

Art of Estimation–my thoughts

I read this post by Ian Battersby about estimation and started leaving a comment but it kept expanding so I decided to put it into a post.

Estimation is a very contentious area and fraught with pitfalls both inside and outside of the team.

In my experience developers aren't bad at doing estimating as long as they are fully aware of the domain, the codebase and the actual business requirement not necessarily what they've been asked to estimate, which of course we always know all the time.

Thursday 18 August 2011

A response to “Agility is not enough: Beyond the manifesto”

I recently came across this article by Steve Denning and within reading a few paragraphs I was disagreeing with the majority of what he was saying and I heard echo’s of management from years past, before I become a software developer, when I worked in sales and customer service.

My main point of disagreement, and possibly what Steve got push back on in his session, is around “delighting” the customer. Don’t get me wrong I want to be able to make my “customers” happy but as a software dev/team lead I have multiple customers to satisfy ranging from immediate and upper management through external clients to actual users of the software/website who may (or may not) be customers of the business.

I’ve not gone through Steve’s points in the order that he wrote them more in the order that I was most annoyed about what he had said, I will warn you now that is an extremely long post but hopefully worth the read, if you don’t have the time you could skip to the conclusion at the bottom and my rant Smile.

Monday 1 August 2011

Progressive.Net Tutorials

From September 5th to the 7th Skills Matter and London .Net user group are organising The 5th Progressive .NET Tutorials which are being held in at Skills Matter eXchange in London.

The tutorials are a series of twelve 4-hour hands-on Workshops which provide a deep dive into advanced topics for Agile .NET developers and I’m hosting one of the workshops!

My workshop is all about agile and given that I’ve got 4 hours you can be certain that I’m going to make sure everybody that attends will leave knowing why we use agile, what it gives us, the various methodologies currently used and the latest thoughts about what we could/should be doing.

If that wasn’t enough there are a whole host of other fantastic speakers: Christian Hassa, Gaspar Nagy, Ian Cooper, Sebastien Lambla, Dylan Beattie , Simon Brown, Paul Stack, Damjan Vujnovic, Adam Granicz, Ian Robinson, Mark Rendle, Steven Robbins, Jon Skeet and you can be sure that they’ll all be covering their respective subjects in great depth.

Unfortunately this isn’t a free event and it will cost you £425 for the 3 days but given that all the sessions are going to cover the subjects in great depth and hosted by experts in their fields hopefully you’ll think that its not a bad price for what you’ll learn.

For full details of the event and to register go here to the Skills Matter website.

Hopefully I’ll see you there but if not then keep up with what’s going on by following the hash tag #prognet on twitter leading up to and during the event.

Friday 15 July 2011

Software Developer != Zen Warrior

Over the last few of years we’ve seen the terms katas, dōjō’s and koans enter the vocabulary of software developers, if you spend some time looking into these terms and how they are used in relation to software you’ll find people drawing comparisons between software development and martial arts and I’m telling you here and now that just because you practice software katas in coding dōjō’s and can solve a software koan you are not some sort of software Zen warrior, you are not Neo in the matrix, you’re a software developer. Fact.

Tuesday 21 June 2011

100% Coverage is not enough

Unless you’ve been living under a rock you’ll have heard about code coverage in relation to test driven development or unit tests depending on if your writing the tests first or not.

Now a lot of people who evangelise TDD will often also talk in the same way about code coverage telling you that if you don’t know what code your tests are actually exercising then how can you be sure your code is correct? I have also had conversations with people who believe in TDD but think that code coverage is just a figure and you shouldn’t pay special attention to it.

Wednesday 15 June 2011

DDDSW 3

So Saturday just gone was the 3rd instalment of DDD SW which is held in Bristol at University of West of England where I was lucky enough to have been picked to to give a session on Kanban.
In previous years the weather has been very hot which has caused its own unique issues but this year although the day was nice it was fairly cool which was a welcome relief.
This year also saw coffee on arrival along with rather nice danish pastries which was just what was needed to get you going on a Saturday morning.

Sunday 12 June 2011

Kanban? What is it and how can it help?–DDDSW Presentation

Yesterday I gave my presentation on Kanban at Developer! Developer! Developer! South West explaining what it is, where it came from, how it could help and how to go about using it.
This is just a quick post to list the resources I mentioned at the end of my presentation.
I hope that everybody who saw the presentation enjoyed it and feel free to tweet or email me any questions you have.

Tuesday 7 June 2011

The Guathon 2011

This was the first (and only?) guathon of this year with Scott Guthrie providing sessions on Asp.Net MVC3 and Windows Azure and Steve Sanderson providing sessions on his JavaScript library Knockout and the Async functionality coming in Asp.Net vNext.

The day kicked off with a short introduction from Phil Winstanley about the day and what was being covered and there was a short “pitch” by Paul Stack on Give Camp UK which is a charity event coming up later in the year where developers can pledge time to help create applications for various charities.

With the intro over it was straight into the sessions….

Saturday 4 June 2011

Balance – some closing thoughts

Better learn balance. Balance is key. Balance good, karate good. Everything good.
Balance bad, better pack up, go home.
Mr Miyagi - Karate Kid
I started the week with this quote and I’ve repeated it here as I do sincerely believe that it sums up balance; be it karate or coding if you don’t sort out how to balance the various forces that act on you then you can quickly find things overwhelming you and it can be difficult to get yourself back on an even keel.

Friday 3 June 2011

Balance - Tech

So I know what you’re thinking “what is he on about? how does balance apply to the technology I use?”, well bear with me and I’ll explain.
A lot of developers will learn to code on one particular platform be it .Net, Java, Ruby, etc and frequently they’ll only look at one small part of that library and unless they are made to either look at different parts of the platform or use a different technology they will generally stay with what they first learned.

Thursday 2 June 2011

Balance – Work

Work

For many people work/life balance is a constant struggle, in the previous posts on balance I covered balance at home and socially but you need to crack balancing work with everything else since you spend so much of your life in work.

Because there is so much that I could cover in relation to work I’m just going to focus on a few of things that I feel are important namely your job, passion and burn out.

Your Job

You spend most of your waking hours at your job and it should be where you get paid to ‘geek out’ and exercise your passion for code. It is important that you enjoy where you work and what you do, if not you’ll most likely find your dissatisfaction spilling over into other aspects of your life.

I speak here with very real experience where I had a job that I didn’t really enjoy, oh I could do the job perfectly well but I just didn’t get any real enjoyment out of it and it was noticeable both inside and outside of work.

If you find a job you love it will help with balancing out the other things you need to deal with as it can reduce the amount of coding you feel you have to do outside of work to keep yourself happy, if you find that you are spending more time out of work doing what you love than in work in my humble opinion I would suggest you need to find a new job to give you time to do other things.

Passion

So Paul Stack wrote a blog post on Passion a while back about why he likes working with passionate developers and for him what extra they bring to the table over the person that simply views development as a job. I would consider myself a passionate developer, I love coding, even when not coding I am often thinking about coding and although the stuff I'm thinking about is not complex algorithm's or clever solutions to technical challenges I'm still thinking about it in my own time.

However there is a darker side to passion when it becomes all consuming. A passionate developer can become a thorn in a teams side they may be argumentative, intractable, disruptive and in the worst case bullying. This may be justified by the developer themselves saying that they are only trying to help the other members of the team, they only want the team to do it ‘the right way’, etc.

Now I’m sure that most passionate developers have been guilty of the darker side at one time or another, the question is how do you deal with it? Hopefully you work in a good team who will tell you when you’re going to far allowing you to ‘dial it back’ since you need to continue to work with them but if you notice you are guilty of ‘the dark side’ and your team aren’t telling you then you may want to look at your behaviour, nobody wants to work with somebody like that and you could find yourself isolated.

Balance your passion to do good work in the best way with bringing others along for the ride and although not everybody will be happy all of the time you are more likely to have a better working environment.

Burn out

This a dreaded topic for many geeks, for some its like the bogey man for others its a badge of honour, but whichever one it is its never nice.

So what is burn out? it will vary from geek to geek but often its when you reach a place where you simply cannot bear to touch a computer or think about coding no matter how passionate you are about it and for some geeks that continue to push it when in this state it could mean ending up having a breakdown, which could very well be game over. A lot of geeks fall into the trap of feeling that they have to “beat the project” and it then becomes a personal challenge to ensure that they “win” but unfortunately this attitude can accelerate you towards burning out.

I believe I managed to avoid it a few years ago (only my friends and family could tell you if I did or not) when I was on a death march project and attending a computer science course at college part time, it got to the point where I simply didn’t want to be in front of a computer which when you’re job is to develop software is a bit of a problem, luckily for me the project came to an end at roughly the same time as my college course allowing me time to “take my foot of the gas” and when I wasn’t in work just not touch a PC and relax.  This Stack Overflow question about what causes burnout elicited some really good answers including some peoples personal experiences of burnout.

The sad thing is that burn out is completely avoidable, it may be difficult to see it when you’re in the grip of some death march project but if you can see the signs you can do something about it.

One of the obvious signs is the amount of hours you are working, as these start to rise you are becoming more out of balance, then you have the out of hours working that effects your family and/or social life all signs that things are going wrong and I’m not even considering things like not sleeping well or other physical symptoms.

So how do you handle this and avoid burn out? well assuming you are working for a company and not yourself you talk to your boss, its not in their interest or yours to have you burn out since hiring a replacement is likely to cost the company more time and money than allowing you to work normal hours plus you working longer hours should be a red flag to management that the project needs looking at. But what do I do if they won’t listen I hear you cry, well then in all seriousness find another job, if the company don’t value you enough to take your concerns seriously and are happy for you to burn yourself out its up to you to look after yourself and vote with your feet.

If you’re working for yourself its much more difficult but I would suggest that you need to look at your longer term goals as “killing” yourself over a project isn’t going to help your business grow in the future, only by balancing your need to work vs. your need for down time can you make the business a success.

Next

I turn to the tech you use and how balance can play a part there as well, even if you don’t see how it can.

Wednesday 1 June 2011

Balance – Social

So you’re a geek but that doesn’t mean you don’t have a social life, sure some of us aren’t great in crowds of people but we all like to get out and enjoy ourselves and should do so to keep us in balance.

It can be very easy to stay in front of the PC/Laptop and lose yourself in coding or gaming and not actually leave the house much apart from going to work and if you’re single possibly not seeing many people. When I was a lad gaming was generally a solitary past time but nowadays with online gaming you can be part of a much larger community of people and you do get to talk to other people but it isn’t the same as actually interacting with people.

People need to socialise and various psychological studies have shown this, possibly the best well know is Maslows “hierarchy of needs” which usually shown as a pyramid which has 5 levels:

  1. Physiological (base of pyramid) – what you need to live: air, water, food
  2. Safety – safe place to live, job, etc.
  3. Social – friendship, belonging to a group
  4. Esteem – recognition, social status
  5. Self Actualisation (top of pyramid) – quest to reach your full potential

Now with Maslows theory you cannot move up the pyramid unless you fulfil the lower levels i.e. unless you fulfil Safety you cannot move to Social. As you can see social is slap bang in the middle of the pyramid, people need to socialise and feel that they belong to a group.

You’re probably asking yourself ‘and?’, my point is that to have balance in your life you need to be interacting with other people, to grow as a person both professionally and personally social interaction helps you in many ways such as improving communication skills, empathy, etc these are all things that will help you inside and outside of work.

Networking

In a recent discussion at DDD Scotland one of the attendees was telling me how he was having to introduce himself as his twitter handle as that was how people knew him. This was backed up later when a comment was made in the “Ask the speakers” session that for a lot of people twitter has become where they most interacted with other people.

Now there’s nothing wrong with having an online network but if you only rely on this and nothing else then in my opinion I believe you are missing out.

If you take the time to go to a local user group or alt.beers you get a better balance between the electronic and social networks and you’ll be surprised who you meet.  Attending a group you more likely to grow your network of contacts and you are you’ll get to see good presentations or at the very least get away from a screen and have a beer with like minded geeks and talk tech & gadgets.

Focus on who you’re with

In my post about balance and family I mentioned a quote by Scott Hanselman’s wife in the disconnecting episode of “This Developers Life” which, paraphrasing,  is about you effectively saying you value the people online more than the people you are with.  This particular quote came back to me at the dinner held before DDD9 when talking to Guy Smith-Ferrier who observed that he looked around the table and out of the 10 people 8 were on their phones twittering away rather than talking to the person next to them!

Guy’s point was that people should actually talk to one another when they were together, a sentiment echoed in the comments to this blog post where the blogger believed it perfectly acceptable to effectively ignore the people he was with to “check his phone” but I think you’ll find that the majority of people believe the opposite, just read the comments to see what I mean.

When you are out with friends/colleagues they may well understand the need to keep up to date with twitter but just do it in moderation and balance it with interacting with the people around you and never whilst in the middle of a conversation.

Next…

Next up I’m covering balance in work including the subject of burnout.

Tuesday 31 May 2011

Balance – Family

When you're a single geek who loves code your free time is often taken up entirely by code and you’re happy and nobody else is involved; then you may meet someone else and find that your time isn’t entirely your own so what do you do?

Family Time

If you’re lucky your other half will understand your love affair with code and let you have time alone with your PC but even at this point you need to be careful to balance out the time that you spend “geeking out” instead of spending time with your other half, although they are there for you and understand why you have to spend time at the PC they still need to feel wanted otherwise you run the risk of them feeling like they are being taken for granted and that is never a good position to be in and ultimately they should be more important to you than the code.

If you are blessed with kids then most likely you’ll find the majority of your spare time disappearing, if you aren’t playing with the kids your other half probably wants you to spend time looking after them which then squeezes out time to continue your love affair with code but, and this is only my opinion, I’d make sure I spend my time with the kids, as a friend said to me recently the latest technology is unlikely to be that important in 10 years but your family will still be important in 10 years.

Social Networks

The one thing you are very likely to hear when with the family are phrases such as “are you on that computer again?” and “would you put that phone away!” and my bet would be you are most likely to be on a social network, probably twitter, and I’m guilty of this myself. Now in the Disconnecting episode of 'This Developers Life' Scott Hanselman’s wife made a statement which struck me (paraphrased here):
When you are with the family but spend the time ‘playing’ with your phone what you are saying is “the people you are interacting with on your phone are more important than your family, even though your family is here and they can be thousands of miles away”
This really made me think. I have some good friends on twitter but I get very little time to spend with my family as a whole (kids are usually in bed in the week) and so I want to spend what time have have with them actually with them. So this has lead me to making a decision where I disconnect at weekends so from Saturday morning to Sunday night I don’t go on twitter or code, I ensure I’m focused on the family and what they want/need to do.

Out of hours coding/learning

“Find a job you love and you'll never work a day in your life.”
Confucius
If you’re a passionate geek then the above saying will make perfect sense to you, if your job allows you to ‘geek out’ at work using your skills and learning new tech then probably won’t feel like you are working at all, which for most techies is nirvana and if you are in that situation then balancing work with everything else in your life will be a whole lot easier.

For lesser mortals who at best only like their job and most commonly don’t have time to keep up with tech in work time you need to take time out when not in work to do this and it is this that can cause you issues.
But all is not lost! Balance here is the key, your other half will know you want to spend time geeking out (or are perhaps in a death march situation) and as long as you make some time to be with them, look after the kids for an hour, or it could simply be to have a conversation with them then in my experience you’ll find them happy to support you in the death march situations and even allow you time alone with the PC to geek out every now and again.

If you are a train or bus commuter then you do have another option you may be able to use that time to get your tech fix be it reading a book on the latest tech or something you don’t know about, or you are able to get the laptop out and do some coding and doing that really helps with spending time with the family.

Next…

I’ll tackle balance in your social life related to work.

Monday 30 May 2011

Balance

Better learn balance. Balance is key. Balance good, karate good. Everything good.
Balance bad, better pack up, go home.
Mr Miyagi - Karate Kid

As Mr Miyagi says Balance is key, and balancing out the various aspects of your life is possibly one of the most difficult things you have to do on a daily basis even if you don’t realise it.

So what am I on about? Well balance has many definitions in the dictionary but the closest definition to what I’m on about is:

mental or emotional stability

So is the am I on about your mental stability? Not really. To be honest I prefer Mr Miyagi’s quote as for me it conveys what balance is all about and if your balance is off then you need to fix it or its likely to lead you to a bad place…….

As geeks we frequently focus on code and tech, they are the core and centre of our very beings but it is possible that this love affair can end up being very imbalanced with us focusing on things that aren’t necessarily the most important things to us although we perhaps don’t realise this at the time.

I had originally intended on only writing one post but as the post increased in size I decided to split it up into a series of posts to make it easier to read , so I’ve now got  a series of posts in relation to balance covering :

  • Family
  • Social Life
  • Work
  • Tech

These post are very much my opinion on the subject and in no way do I promise to have all the answers, but this post has for me become the itch I had to scratch and I wanted to share my thoughts and experience in relation to these things in case it can be of any help to anybody else.

First up…

I start with my thoughts on balance in relation to family specifically where you have an other half and children.

Tuesday 19 April 2011

Don’t use ConfigurationManager!

.Net is generally has a nice API but something's are problematic when the classes are static, like FormsAuthentication or ConfigurationManager, allowing developers to use them anywhere in the code.

If you’re one of those dev’s that slaps a ConfigurationManager.AppSettings in the middle of a class then stop, please just stop.  I know that it works but the side effect is that you’re creating a hidden dependency that dev’s who come along afterwards to maintain the code know nothing about and then get bitten in the ass when they try to change something (yes I know you should look through the code for things like this but I was in a hurry ok?)

To be clear, I believe that settings should be injected into classes that need them rather than having to provide a whole object to handle it (think of a connection string) but if you're refactoring old code and already have the dependency then its good to be able to start off by being able to see the dependency rather than have it hidden.

I know what you’re going to say “but its a static class so I don’t have any other way to use it”, but that’s where you’re wrong and with a little work you can have dependency injected, unit tested code loveliness and in fact I’ve done the work for you all you have to do is reuse it!

So what’ve I done? Well quite simply just written a wrapper around the ConfigurationManager’s static methods that allow you to use it via an interface and inject it into any classes that may need it, lets look at some code to see it a little clearer.

Here we have an absurdly simple example that demonstrates that just looking at the public interface of this class you’d have absolutely no idea that it uses ConfigurationManager internally:
   1: public class SomeClass
   2: {
   3:     public void SomeMethod()
   4:     {
   5:         int value = int.Parse(ConfigurationManager.AppSettings["TheValue"]);
   6:     }
   7: }

At least with the code above you may go investigating “what lies beneath” and find the hidden dependency but what if you came across this:

image

My guess is like me you’d anticipate that the class had been sorted for dependency injection and only needed the 2 dependencies that its constructor was advertising and it wasn’t until you got bitten by a problem that you’d look at the code and find:


   1: public class SomeClass
   2: {
   3:     private readonly IDependency1 _firstDependency;
   4:     private readonly IDependency2 _secondDependency;
   5:  
   6:     public public SomeClass(IDependency1 firstDependency, IDependency2 secondDependency)
   7:     {
   8:         _firstDependency = firstDependency;
   9:         _secondDependency = secondDependency;
  10:     }
  11:  
  12:     public void SomeMethod()
  13:     {
  14:         string theSetting = ConfigurationManager.AppSettings["TheValue"];
  15:  
  16:         theSetting = theSetting + "ArbitaryValue";
  17:  
  18:         _secondDependency.TheSetting = theSetting;
  19:  
  20:     }
  21: }


So the solution to both of these problems is to inject the ConfigurationManager into the clas and to do enable us to do that step forward IConfigurationManager.

The code is written in .Net 4.0 but should work with .Net 2.0 and above if recompiled to target whatever version of the framework you are working with.  For brevities sake I’m just going to show the second code snippet using IConfigurationManager which makes the code look like this;


   1: public class SomeClass
   2:    {
   3:        private readonly IConfigurationManager _configurationManager;
   4:        ..... 
   5:  
   6:        public SomeClass(IConfigurationManager configurationManager, IDependency1 firstDependency, 
   7:                         IDependency2 secondDependency)
   8:        {....}
   9:  
  10:        public void SomeMethod()
  11:        {
  12:            string theSetting = _configurationManager.AppSettings["TheValue"];
  13:  
  14:            theSetting = theSetting + "ArbitaryValue";
  15:  
  16:            _secondDependency.TheSetting = theSetting;
  17:  
  18:        }
  19:    }


Now anybody looking at the public interface for this class can see that it has a dependency on IConfigurationManager which in turn should indicate that the code is going to be reading from a App or Web.config. The only difference to the actual code using the configuration setting is the use of the instance variable rather than the static class.

The actual IConfigurationManager project contains the implementations of both ConfigurationManager and WebConfigurationManager (plus tests) to show that you can use IConfigurationManager to replace either of these classes. Currently only the more common methods & properties have been implemented as following the principle of YAGNI I’ve not bothered adding methods such as OpenExeConfiguration that I don’t need at the moment.

The one extra thing that I have added is the ability to be able to return a strongly typed custom configuration section rather than retrieving a section as an object and then casting it, so instead of :


   1: var sect = ConfigurationManager.GetSection("sampleSection")as SampleSectionProvider;

You can do:

   1: var sect = _configurationManager.GetSection<SampleSectionProvider>("sampleSection");


I know there’s not a lot of difference but I prefer the generic version since an error will be thrown if it can’t get the appropriate section handler that’s been specified.

One word of warning the Core project has a dependency on System.Web this isn’t a problem for me as I’m mostly using this with web projects but if you wanted to use this with a desktop app you will need to either remove the class from the project or except the assembly dependency.

If you are using ConfigurationManager then I strongly recommend trying out IConfigurationManager, if not for you then for the person who has to maintain the code in a few months time Winking smile

Tuesday 12 April 2011

Up and coming presentations

Conferences

I’ve been lucky enough to have presentations voted for in both the upcoming DDD Scotland and DDD South West.

The “Is your code S.O.L.I.D?” presentation is heading north of the border to Glasgow on the 7th May for DDD Scotland, registration took place on 1st March so hopefully if you wanted to come you’re all sorted, otherwise commiserations.

June will see me back in Bristol giving a new presentation “Kanban? what is it and how can it help?”, registration for DDD South West opens today at 10am so be sure to be standing by your browsers and ready to register if you want to attend.

User Groups

As well as presenting at the conferences mentioned I will also be taking my “Is your code S.O.L.I.D?” presentation on the road, firstly to .Net Developers Network in Bristol tonight and then to NxtGen Shenfield on 26th April.

Hopefully I’ll see you at one of these events, please feel free to grab me for a chat and if you’d like me to present at your user group then drop me a line Smile

Monday 4 April 2011

Book Review: Dependency Injection in .Net

So Manning Books have been were kind to me again and have let me have another book to review namely  Dependency Injection in .Net by Mark Seeman.

Before I got this book I thought that I had a fairly good understanding of what Dependency Injection (DI) was all about but when I opened the book and found out there were 500+ pages I thought that I obviously didn’t know a lot!

When you take a closer look at the contents you find that its split into 4 parts:

  • Introduction
  • DI Catalog
  • DIY DI
  • DI Containers

The book is structured so that a complete newcomer to DI could read the book cover to cover and learn all about it or if you already have experience you can jump to the parts that you don’t know about or your knowledge isn’t that in depth.

Introduction

The introduction is a little more than it sounds as it comprises 3 chapters starting with introducing DI itself before moving on to  DI fundamentals and DI containers.

These 3 chapters give anybody who doesn’t know anything about DI a through grounding in what DI is, how DI works and what DI containers are for and how to use them.

You will also be introduced in these chapters to 2 themes that run throughout the book, the first being how to create a sauce béarnaise and how it has similarities with DI, and the second is Mary Rowan a developer who is creating an application and we can see how DI helps in that process.

DI Catalog

This section introduces you to a lot of the theory around DI listing patterns and anti-patterns and it covers how to refactor code to be able to use DI.

The chapters on patterns & anti-patterns give you the name and details of each and are backed up with code examples so you can see how each is implemented, and in the case of anti-patterns what you can do to alleviate the problem.

The third chapter is devoted to refactoring existing code towards DI and covers a load of scenarios such as cyclic dependencies and constructor over injection to name two.

DIY DI

This section details how you can implement DI yourself, otherwise known as “poor mans DI”, and runs through the 3 key concepts: Object Composition, Object Lifetime and Interception.

Each concept has a chapter devoted to it with Mark explaining the concept and then showing how you can code it yourself increasing the complexity of the code as each chapter progresses.

The chapter on Object Composition in particular shows you how it works with various technologies such as console applications, Asp.Net MVC, Asp.Net Webforms, etc.

DI Containers

The final section of the book takes you through some of the more well known DI Containers and how they satisfy the concepts laid out in the previous section.

This section differs from the others in that it has 6 chapters rather than 3 with each DI container having its own chapter, the containers currently covered are:

  • Castle Windsor
  • StructureMAP
  • Spring. NET
  • Autofac
  • Unity
  • MEF

Summary

This book provides everything you need to know about DI ranging from what it is, through patterns for implementing and key concepts, to covering various DI containers that are available today and whilst the book is aimed at the .Net world I believe that it would be useful to any developer that wants to implement DI it whatever language they use.

This isn’t just a theoretical book as every step of the way demonstrates each subject covered with code examples so that you can see how you actually use the subject in question rather than having to try and work it out for yourself, yes the code is ‘demo’ code but you can easily see how you actually implement what is being discussed.

The only niggle I have is that the DI Container Ninject isn’t covered in the book, this was specifically mentioned in the MEAP forums for the book and Mark said the reason for this was he was unaware of it until after he had completed the DI containers section and it was too late to add further content. A poster on the forum suggested Mark could create a separate downloadable chapter on it to which Mark said it sounded like a good idea.

This book is not due to be published until July but is available now through the Manning Early Access Program (MEAP) and Mark has said that the content is now basically complete and the remaining changes are likely to be typographical. 

Many thanks to Manning Books and Mark Seeman for the opportunity to review this book.

Monday 28 March 2011

Certified Scrum Professional

Chances are you’ve never heard of the Certified Scrum Professional (CSP) certification, you’ve most likely heard of the other certifications – Scrum Master, Scrum Developer, Scrum Product Owner, Scrum Coach, Scrum Trainer but the CSP seems to not have had as much publicity which is a shame.

So you’re probably asking what is the CSP? well the Scrum Alliance has this to say:

“Taking a course introduces you to the basic concepts, practices, and principles you need to fulfill your role on the Scrum team. But there are certain things about an agile approach like Scrum that are only learned through time, experience, and continous learning. If you are an active CSM, CSPO, or CSD who has reached that next level of experience and expertise in the art of Scrum, share that accomplishment with others by applying for a Certified Scrum Professional credential.”

So its a certification that is based on actual experience with Scrum, not a 2 day course about concepts, you need to show that you can and have applied the concepts and principles and to me this is far more valuable than a certificate for attending a 2 day course.

I believe more should be made of this certification as to a potential employer this should show that the person they are looking at knows about Scrum and has shown that they have implemented it on a project (or projects).

My application

So following on from my Certified Scrum Master course I applied for the CSP, I met all the prerequisites (have existing certification and at least 1 year of active Scrum practice), so I downloaded and completed the application form where I had to provide details of my experience with Scrum and how it had been used plus a  few questions relating to the concepts & principles behind scrum itself.

My only issue with the application process was that the form was in Word and used word fields for the area’s which gives the impression that you should put your details in these fields, which I did, but when you get to the end of the form it tells you that you have to print it off, sign it, scan it in and mail it back.  I do have to ask if in the 21st centaury can we not come up with a better way of dealing with this?

I then submitted this application which goes through a process of being reviewed by the Certification Review committee (which in my case involved 2 separate people reviewing the application) and I was recently told that I had succeeded in my application.

This means I am now a fully fledged Certified Scrum Professional having been recognised by a professional body of having real world experience with Scrum.  My hope is that will strengthen my CV and stand me in good stead with current and future employers and if along the way I am able to publicise the CSP a bit more and raise peoples awareness of the certification then so much the better.

Tuesday 22 March 2011

Why Internet Explorer will never be a ‘cool’ browser

So IE9 was released last week and there was a flurry of tweets & blog posts about its problems and this got me thinking about IE as a browser and why, IMHO, it is unlikely that IE will ever be a cool browser.

So lets break the problems down in much the same way that the blog posts & tweets did: Installation, upgrade cycle, previous versions, performance, display.

Installation

Many tweets and a few blog posts complained about the need for a reboot once installation was complete or that when they came to install IE9 that it requested a number of apps be shut down before proceeding.

The reason behind this as far as I can make out is the tight integration between IE9 and hardware via the OS, which effectively means that your new shiny web browser is really an extension of the OS its running on rather than a separate application.

This then is the reason that you have to close programs, or at worst reboot, and in fact in a positive light the fact that for many people they only have to close programs rather than reboot could be seen as a big step forward.

Upgrade Cycle

Now there’s a couple of reasons that I can see that will mean IE won’t ever have an upgrade cycle like Chrome or Firefox, the first one we’ve touched on already being the tight coupling to the OS the other reason is the use of IE in the enterprise.

So if we have a browser coupled to the OS making changes is going to be difficult since any change to the underlying OS due to a patch could effect you and also something you do in developing the browser could cause a problem in the OS.  This then leads to a slower development cycle as you need to ensure everything is ok as you develop so that you don’t end up with an unstable application or worst OS.

Within the enterprise space I would bet fairly heavily that IE is the dominant browser and in this IE could be a victim of its own success. Most enterprises don’t move versions of software very quickly as they will want to make sure that all software that they have which uses the browser isn’t broken by implementing a new version, and in my own experience I’ve actually seen software that works with IE6 but not with IE7 or above.  What this can then lead to is problems with other software having to be upgraded/altered before a new browser can be rolled out which can be expensive which can lead to no change at all.

Since Microsoft listen to their bigger enterprise customers it may have an impact on the release cycles since as much as we geeks bitch about it we don’t actually contribute to the profits in a big way like the medium & large enterprises do.

Previous Versions

More than one blog pointed out that there are now 4 different versions of IE ‘in the wild’ but IE is not alone in this as Firefox also has 4 and I’m willing to bet there are other browsers out there that still have older versions.  Look hard enough and you’ll probably find an IE4 somewhere.

There will always be older versions of applications be they web browsers or any other software it is a decision to be made by a business as to what they will support, IE is not alone in this so I don’t think any blame can be attached to it.

Performance

The speed of any of the browsers is a hotly contested thing and IE9 was touted as being very fast and I will admit I never found IE9 to be any faster, then I found this article which shows a decent comparison between Chrome, Firefox & IE9 and explained why.

It would seem that if you installed the 32-bit version of IE9 you got the new JavaScript engine but if you installed the 64-bit version you got the IE8 JavaScript engine.

Now I think that this is pretty unforgivable, if you’re going to release a new app with a new JavaScript engine to make it fast it should be supported on all versions, if not then why release that particular version? (thinking of 64-bit here)

So I’m going to be uninstalling my 64-bit version and installing the 32-bit version to see how fast IE9 appears to be for me.

Display

There weren’t many people complaining about display issues but this article showed that for some people IE still isn’t complying with standards or even a modern browser but I haven’t seen many blogs or tweets that are specifically complaining about these display issues.

Summary

So why won’t IE be a cool browser?

  1. Always likely to need a reboot due to tight coupling to OS
  2. Tightly coupled to OS which means slower release cycles
  3. Used in larger enterprises so pressure from them to not upgrade so quickly
  4. Some display issues and question marks over if its support of standards

Does all this mean IE9 won’t be a success? of course not! IE9 will be a success because most of the people on the internet aren’t geeks and if they are using windows they will update when Windows update pushes the app to them.

Having said that, it still doesn’t make it cool.

Tuesday 1 February 2011

DDD9!

Last Saturday I not only got to attend DDD9 I was lucky enough to have a session selected so I was speaking as well.

Pre-Conference Dinner

The night before the conference there was a bit of a get together and a chance to chat with other people who were going to attend the conference the next day and it was great to catch up with people over a few drinks and food.

DDD

.Net Collections Deep Dive – Gary Short

Gary’s talks are always great and so I was really looking forward to this one.

From this session I learnt a lot about the different types of collections and Gary’s insights about their foibles was invaluable and will help me in future when I’m deciding what collection to use rather than just plumping for a List<T>.

Monads! What are they and why should I care? - Mike Hadlow

As I wanted to ensure my presentation was ready I missed the beginning of Mike’s presentation and joined it about half way through.

Mikes session was one where I really needed to have been in since the beginning, it was an excellent presentation and very technical but coming in half way through I had trouble keeping up (my fault not Mike’s) .

As I tweeted on the day monads look really interesting but I’m not sure where I’d use them in C#.  As I said in my post about the year ahead I hope to look at F# and can see that monads may be very handy.

Writing Maintainable Tests for Selenium - David Burns

I was looking forward to David’s session as I have been using Selenium for a while and wanted to see if I could improve my tests.

I was pleasantly surprised to find that I have been following best practice without even knowing it.  I think that David’s talk ended a little earlier than he anticipated but the questions and discussion that filled the rest of the session were good.

Is your code S.O.L.I.D ? - Nathan Gloyn

Yes this was my session!  I had a good time presenting it and from the feedback it seems to have gone down well, I’m going to be presenting it again at some user groups in the near future and I’m hoping it will be selected for DDD Scotland.

Mobile Panel - From iPhone to HTML 5 to Windows Phone 7 to Android - Chris Hardy

The final session I attended of the day was a panel that took questions from the audience on various topics relating to mobile technologies.

The questions included security in relation to mobile devices, tablet PC’s, HTML 5, best platform to develop on, etc

The panel answered all the questions and even posed some to the audience to try and find out the feeling in the room about where mobile technologies were going and what platform’s people intended to develop for.

Geek Dinner

So after the conference finished was the geek dinner which kicked off as per usual in Revolutions bar for pre-dinner drinks and then moved onto Pizza Express.

It was great to be able to talk to other speakers and attendees to gauge how the day had gone and the feeling was that this was the best DDD so far, a good mix of introductory, deep dive and technical sessions.

Summing up

From the pre-conference dinner through DDD to the geek dinner this was a great DDD. I really enjoyed meeting friends old and new and the discussions that we had.

The DDD team did a fantastic job of organising the whole day and I’m sure that everybody who attended would agree that the actual day and the dinners, before and after, were a great success.  Well done chaps!

So what’s next? Hopefully DDD Scotland and after that DDD Southwest 3, see you there!

Saturday 29 January 2011

Is your code S.O.L.I.D?–DDD9 presentation

Earlier today I gave my presentation at Developer! Developer! Developer! 9 on S.O.L.I.D principles.

I considered creating a series of post on the principles but a quick search showed so many already on the internet that I decided against it, in fact searching for SOLID principles on Google resulted in Google telling me it had about 30,800,000 results.

Instead this post contains the links to the resources and code that I promised at the end of the talk.

So this is that list and I hope that everybody who saw the presentation enjoyed it and feel free to tweet or email me any questions you have.

Books

Agile Principles, Patterns & Practices in C# – the seminal work

Web Pages

Presentation slides

The slides for the presentation can be found here, I'd recommend downloading them as the Google doc viewer doesn’t display the slides correctly.

Presentation Code

The code that I used in the presentation is on GitHub which also has a wiki explaining the changes that were made between each project to meet the principle.

You can get to the code here.

Thursday 13 January 2011

Pex & Moles

Last night at .Net Developer Network Steve Strong (@srstrong) gave us a presentation on Pex & Moles which has been created by Microsoft Research.
I first heard of Pex a while back (possibly 2 years ago now) and whilst I liked the look of it dependencies were a problem and so I didn’t pursue it any further, so I was especially interested to see Steve’s presentation and see how it had changed.

Pex

Pex is a Visual Studio add in for VS2008 and VS2010 which will create parameterised unit tests for your code, it aggressively (I’ll come back to that in a minute) goes through your code trying to create sufficient tests to attempt to get 100% code coverage.
Pex is fairly non-partisan about what unit test framework it uses and will just as happily use NUnit, MbUnit, etc as it will MSTest.
Pex will generate tests, including failing tests if the code doesn't work the way it thinks it should work.  These are created as normal tests that you can run individually just as you normally would.  If you have created any tests yourself then Pex will use those tests to improve the quality of the tests that it creates. 
Although Pex will do a fairly good job of test creation you should review the values it uses for the tests to ensure that you are happy about the values in case it has missed something or is using data which is just plain wrong; Pex does offer a host of functionality so that you can influence the data it creates restricting ranges, min or max values, etc.
Pex works by instrumenting the IL generated for your code so that it can track the various paths that are executed allowing it to then feed in various values it generates to exercise your code, these include some default values such as null, MinValue, 0, etc.
As I mentioned earlier Pex goes through your code aggressively, this means that it looks at your tests, your code, any libraries you use (including standard .Net assemblies) and attempts to follow as many branches through the code as possible.  On a practical note Pex may fail to be able to create tests to give 100% coverage if it cannot satisfy itself that it has exercised a branch in the code sufficiently, so the more complex the code the less likely Pex will manage to create the tests.  Because of this Pex is not suitable for system testing as the possible branches across a system will be just too many for it to create any meaningful tests.

Moles

Ok so you’ve got this great tool that can generate you tests but you need to mock dependencies such as a database so what do you do? You could try using Rhino Mocks or Moq but you run straight into the problem that Pex will attempt to go through the entire mocking library assembly and test that.
[Edit:] Another reason that Rhino & Moq are likely to cause problems is that because they generate new classes under the covers Steve was unsure exactly what Pex would do about those particular classes [Edit]
So the Pex team came up with Moles, which is not really a mocking library but a stubbing library, to allow you to stub your dependencies.  The way it does it is the usual sub typing method which does mean that you can’t stub the normal suspects (sealed classes, static classes, value type, etc) but Moles will go through an entire assembly and generate a mole for each type in that assembly that it can stub, included generic types as well, without you having to do it all yourself manually.
What you can then do is determine the behaviour of a mole by assigning delegates to the properties/methods of that stub and because the mole code is so simply pex is unlikely to ‘choke’ on it when observing your code.
Moles also come with behaviors (yes it is spelt correctly) and using these behaviors you can determine what the code should do for any properties/methods that you don’t explicitly provide an implementation for.  It would appear that moles work in a similar way to TypeMock and as such they are able to intercept calls in your code that normally would not be accessible to normal mocking libraries.

So are they any good?

What I’ve mentioned here only really scratches the surface of what Steve covered and you need to see Pex in action to appreciate what they can do and functionality that is available.
Steve did say that he believed you would end up using Pex to generate tests for your code and hand crafting specific tests to cover business logic that Pex just can’t get e.g. behavioural tests.
I will say that based on Steve’s presentation I will be taking another look at Pex & Moles for my code.

Many thanks to Steve for the presentation and Guy as always for organising the evening.

Tuesday 4 January 2011

That was 2010, here comes 2011

Like so many others I thought I’d put a post together looking back at what happened in 2010 and what’s ahead for 2011.

2010 the year that was

So what did happen in 2010? Well looking at my blog posts I started the year going on about Asp.Net Dynamic data as I was using it extensively at the time and wanted to brain dump about it.

Then at the end of March I changed jobs and moved to a medium/large enterprise (dependent on your definition of size) and my focus then changed to Scrum with several posts (starting here) by myself on the state of Scrum in my new job and how I worked with the ScrumMaster to fix them.  I also got my Certified Scrum Master and have applied for Certified Scrum Professional (CSP).

After I made a ‘harsh’ comment about a presentation at DDD8 I was challenged to do better myself and that started me down the path to give presentations, starting with grok talks at .Net Developers Network on Selnium (slides available here) and Asp.Net Dynamic data. I then went on to give presentations at DDD South West and DDD Ireland 10 about Scrum.

The commute to my new job is on the train and I used the time to catch up on some reading and finally managed to read some ‘essential’ books such as Code Complete, Clean Code, Extreme Programming Explained, etc and I started to review books for Manning books my favourite so far by Jon Skeet’s C# in depth 2nd Edition.

The one thing I didn’t do a lot of in 2010 was green field development in work, it was code verification, refactoring and for the majority of my time getting the team to work well together and really understand Scrum, however, I did do some of my OSS project which I haven’t released into the wild yet.

2011 the year ahead

So what do I want to do this year?

Well I want to build on what I did last year with more user group presentations (anybody interested give me a yell) and have made a good start by having my session Is your code S.O.L.I.D? accepted for DDD9 on 29th January.

My reading will continue, currently reading Agile Principles, Patterns and Practices in C#, looking to read more essentials such as Refactoring: Improving the design of existing code and hoping to continue doing some more book reviews for Manning as I’ve really enjoyed that so far.

I’m hoping that my CSP application will be approved as that will be the last scrum certification I will look at doing unless I decide to go for Certified Scrum Coach, but that’s unlikely at the moment.

The one thing I’m hoping will change is the amount of development I get to do;  I'm looking to get my OSS project into the public domain and also an example of the Repository pattern that I’ve been working on (expect blog posts soon).  In the work place I’m looking at implementing continuous integration first for automated builds and then testing, not sure if I’ll get to automated deployment yet.  If I do manage to find the time, and I really hope I do, I want to look at F# and Ruby but it will probably depend on other commitments as to whether I get the time to do this.

The one thing that I would love, but wonder if its possible, is to earn a MVP but it may not be possible this year (or the next) I need to get more involved in community events, etc.

Right then, best get to it.