Sunday, 28 December 2008

Don't Tweet Drunk


The latest meme on Twitter is for twitterers to blog about Twitter and then tweet it so that it can be retweeted. We all sit around and read it and retweet in agreement or scroll on with a little bit of passive aggression.

Since I'm an individual just like everyone else, here is my Twitter post of choice. It addresses the eternal question asked by those outside the twitterverse about what this is all about - What is Twitter and why should I use it?

My first response to that is usually that you don't have to use it. You could go on for the rest of your life not using Twitter and not feel as though you have missed anything. On the other hand, if you do try it out then there are a few things you will experience and gain that are not so easy to list out and debate over Chinese food. These things are additive, like MSG. They add flavour but some people may not react well to it.

Networking
This is networking in whatever sense you want. If there something that you are in to then there are micro-groups on Twitter that share in your passion and will not hesitate to help or support you with your common pursuit. If you want to connect with people around the globe who can encourage your "thing" then Twitter is your forum.

I use Twitter to network with geek girls; software engineers, ThoughtWorkers; friends around the world; and family.

Reading
I use Google Reader less and less to find things I want to read when I'm not rushing around and have time to stop. Instead I steadily open in my browser the links that people tweet about that sound interesting to me. These are sometimes things they produce but most often are links to other places on the 'net. From this I find new things to read and subscribe to that I would not have found on my own in the lifetime of the universe. The Interblag is a big place and following people with common interests can introduce a new source of information to the pool you have already collected.

Thinking
I often find it useful to share my thoughts with people on Twitter and then discuss them in order to articulate what I think. There are many intelligent and switched on people out there who will actively discuss things with you.

Yeah, it is nice to talk about what you are thinking at the time but the coolest part is listening to interesting people bring up ideas that make me you think. Ideas that challenge your own thinking. Ideas you may never ever agree with but are willing to listen to because it's not being shoved down your throat.

On this point, you must be very careful not to get caught up in group-think. This is very easy to do on Twitter. People do complain regularly that there is too much of this on Twitter and that us being to nice and cuddly towards each other is killing original and critical thought. I do see the danger but also believe that an encouraging environment that allows you to test your assumptions and be wrong without fear of the fail whale pushes creativity and individuality. That in itself can overcome the memes that drift in and out of this growing nest of communities and networks.


Twitter is not for everyone but there is a place for you if you choose to follow. It's something different to every person. For all I've expressed here, there will be someone who sees it differently and that's just Twitter.

Try twitter. I recommend it.

Tuesday, 9 December 2008

Learning about Testing ASP.NET MVC


Working on my first commercial implementation of ASP.NET MVC Beta has been rewarding and frustrating to almost even degrees. Learning to test the MVC framework after hearing the promises of Microsoft and the choir has proven that it is still young and the road is long. It feels like being back in .NET 1.1 land again but as an eternal optimist, I see that as meaning that ASP.NET MVC has a promising future. As promising as C#, which had humble beginnings.

Abstracting the business value and corresponding actions in to the C part of MVC has meant that the code behind an ASP.NET Page is reduced to nothing more than specifying the type of model that the strongly typed View uses. That solves an enormous amount of problems that came out of the pre-ASP.NET-MVC world. In particular the classic-ASP-like tendency to put all logic straight in to the events in the code-behind with little to no abstraction. Since you can not instantiate a Page object outside of the ASP.NET framework, it was impossible to unit test the controlling logic in the code-behind. When I have walked on to a project and seen the 3000 lines of code nested in page events, I knew it was almost impossible to safely refactor let alone extend the functionality. All changes in that case had to be additive and in no way morph logic so that nothing legacy would be broken.

The ability to test Controllers has pushed that code out in to a testable .NET class that can be instantiated independently of the framework and then easily tested. That's brilliant if you weren't already doing that but most of us were. I do commend Microsoft on forcing some sort of design on to us but as usual it's all mechanism and no policy. It's another easy way to say "put it all here" but also test it.

What I want to see out of future ASP.NET MVC releases is the ability to test Views with simple xpath searches and annotation validators on Models that feed through to the View. Yes, it's not there now but it will be soon as we can see in MVC Futures. This is not a case of Microsoft missing the point at all. They just have to release something and then they will add to it. They have shown their responsiveness to community feedback. If only they wouldn't refer us to stackoverflow.com.

From the conversations we have had with Microsoft, they have started by saying that it's only the Controller that needs testing and that Views should be tested by a UI testing tool like Selenium and that models have accessors only so don't worry about them. There is then the realisation that testing your View as an abstract concept is not a bad one since it is faster and most efficient than using the UI tools with their overhead (even headless). It certainly will let us test state more efficiently. As for models, validation is so important that the lack of access to annotation validators has resulted in an excess of JavaScript (beit jquery) in our application and I'm not convinced that is a good thing yet. Maybe that's my C# bias kicking in.

I for one am looking forward to the MVC futures becoming MVC present. Until then, all the positive parts of this new framework like the ease of integration of the Model, View and Controller make up for all the things I still want. It saves me the time I used to spend on implementing MVC in the old world.

This leaves me extremely optimistic about the future of .NET web development. Until then, let's do our best to avoid the fat Controller.