On.. My Internet Hive Mind

I no longer know anything.  I have ceased to hold knowledge in my brain for long periods.  Effectively my mind has become an array of pointers to actual information sources powered by a sophisticated search and retrieval system.

What has caused this complete emptying of retained knowledge?  The internet.

It is now easier and more reliable for me to look up solutions to problems than to work them out for myself.  A quick search with the correct key words or phrases and I’ll have the answer to my question in minutes.  When presented with a bug, unless it is something very obvious, the error is copied and pasted into Google, in quotation marks with msdn added to the end.  A few seconds later I’ll be staring at the answer to the issue.

Is this bad?  Yes!  I’ve stopped understanding at a level that I would like the issues affecting my code.  I can find an answer, work through the steps to fix the problem, get the code running again and forget about it, without truly understanding what I have just done.  In the long term this can’t be good for the quality of code.

Is there a solution?  Yes!  I work on a couple of applications on the way home on the train each evening.  Its a thirty minute window with no internet access.  If I come across a problem I need to fix it by working through the issues.  If I don’t know how to do something off the top of my head I need to check out what the .NET framework will let me do and what methods are available.  Occasionally I will need to look something up, which I can do when I get home, preferably in a book, but once or twice I’ve taken to the internet for answers.

By trying to limit my internet use I have found that I have a much more complete understanding of the solutions I am building on the train, which in turn means I am fixing bugs faster, and stopping them occurring in the first place more often.

If you are finding you are using the internet as your default bug fixing tool perhaps it might be worth having a “no internet answers” day or try programming and application or a module without referring to the internet for your answers.  If it is overly frustrating at first then you know that you are relying heavily on other people to solve your problems.


On.. Web based adverts

It didn’t come as a huge surprised that the demographic of people that click on adverts when browsing the web are not necessarily the most savvy of people, or indeed the people that you might want visiting your site.

I run a couple of sites that could happily take adverts as a source of revenue, the problem comes that I want the relationship to work for both parties.  Sure I could just bung on some google adwords and get a bit of money each month, but its not good enough, I’ll have no real relationship with the people advertising on my site and no real control over the quality of the products being advertised to my users.  Then there are the users who automatically block adwords and the like, so there is no benefit for advertisers there.

The unfocused and all pervasive nature of internet advertising has created a situation where they are no longer doing what they intended.  What advertising through google and other advert aggregators is basically a scatter-gun approach, spray your message over a large area and someone might see it, hardly the well targeted advertising that might actually achieve some results.

I’m guessing that Adwords and the like must work for some people otherwise they wouldn’t pay for it?  Or is it just a case of hard numbers, it is easy to track so anything that comes through looks like success.

The problem isn’t that Adwords exist, its the fact that a suitable alternative is difficult to come by.  I’ve often considered sponsorship for sites, however I feel that is the road to having to consider your content in relationship to your sponsors.  Maybe this is the commercial reality of wanting to fund your website activities, somewhere along the line you are beholden to someone if they are putting money in.

I’m intrigued by things like Ebay affiliates and the similar Amazon scheme.  They seem much more targeted, for my there is an issue around customisability, I’d like to make them much more dynamic, maybe have the searches and results based on the meta data within the page, or content, yet it doesn’t seem to be able to handle this.  With the ebay one in particular I’d like to make all links on my site to ebay go via my ebay affiliates ID, they don’t offer this as an out the box solution, I can hack a solution together, so it appears that the link came up on one of the searches it displays in its banner, but I’m not sure if I’ll violate some terms of service agreement and forfit and money from it.

The big issue is that if online advertising metrics do start to show a negative correlation between the desired results and the actual results then the bottom falls out of the web, again.  Maybe bubble 2.0 won’t be the result of an over abundance of social networks and candy floss websites, but it’ll be as a result of never getting a proper handle on high quality advertising revenue models.

On.. Platform Vs. Software

I read with a wry smile this morning Paul Stovell’s blog entry for the software super villan that is “Platform Man”. I’m currently living with the chaos that platform man can cause. We are coming to the end of our first phase of Sharepoint development, I argued early on that we should use Sharepoint as a document storage solution and program everything else ourselves. However platform man struck and suddenly Sharepoint was the solution to all of our problems for sites and content management, with “just a bit of customisation”. This was a mistake. We knew this at the time, but platform man stuck and that was the end of it.

So the question is how do we recover from this, Sharepoint is about to become the central tool for information within the company, we don’t want to loose the last years work. That’s right folks a years work to change how the sites look, have our staff members search-able and create a handful of custom web parts. Hardly rocket science for most software developers, but once put through the mangle of the Sharepoint web front end and you are living in a whole world of pain.

The trick when you’ve got yourself in this situation and as you face future developments is to establish scope. What is going to live on your platform. Rather than blithely saying “everything will now go on here” and then spend months working out a way to shoe horn it on. Establish the rules around new work and what your current ‘platforms’ strong points are. Sharepoint as a ‘platform’ can do all sorts of things, but then again Word can be used as a website editor. So you establish what it is you are using it for.

For Sharepoint I’d like to be proposing only documents, web/html content, collaboration space and exchange interaction. Anything that needs reporting on will be in a separate database, anything that wants interaction beyond the standard Sharepoint interaction will be a separate application (ie anything with Ajax or Silverlight). Then there are applications that may need a slick front end by have a document management aspect to them, this is where we use Sharepoints document management with a separate front end to query it, something like an image library would be the perfect example of this.

This means we’d be using each thing for what its best at as well as setting a precedent for future technology buy in, managing to avoid the curse of Platform Man.

On.. Development Nirvana (part 2)

When I looked at how to improve our development processes and environment I gave myself 10 scenarios or stories to deal with. Situations that occur regularly that we could improve, or at least have a set way of doing. This wasn’t a comprehensive list just a starting point, I’m sure in a couple of months I’ll have another 10, but just because you can’t fix everything doesn’t mean you shouldn’t fix something. That may have been a triple negative…

So I’ve taken my 10 stories and written against them what I would like to happen. This makes me clarify what I’m trying to achieve, saying “I want a better development environment” is a fairly empty phrase without detailing how it is you would like to work.

1. Working for the first time on an existing project

What I would like to happen : I open up Visual Studio, load the project from somewhere, get the current working version of the code that builds and connects to the test/sandbox database if required.

2. New project starts up

What I would like to happen : When a new project is authorised, rather than a personal local development, it will create a centralised project store, an intranet site to track documents or progress, and it will send an email to certain people to announce all of this has occurred.

3. Project finishes

What I would like to happen : Code is stored as a release version, intranet site and documentation are moved from a project location to a reliable information store as a reference point. Post project documentation is completed and added to the site.

4. Team working on same application

What I would like to happen : Members of the team should be able to edit files within the same solution and within the same project. They shouldn’t be able to edit a file that someone else is currently editing. They shouldn’t be able to add or update files to the solution/project that will stop it from building, or that don’t conform to our coding standards. I should be able to find out who lasted edited a file, or indeed particular lines of code.

5. Error occurs in code during development

What I would like to happen : It will be easy to find out who last edited a piece of code, or one of its dependencies, it will also be easy to find out why that line of code was edited and who the project owner is.

6. New application needs to be deployed

What I would like to happen : An installer is handed off to one of the IT or infrastructures team and they will be able to deploy it in the required environment with minimal amount of setup. It will work.

7. New Webpart needs to be deployed to Sharepoint

What I would like to happen : A Webpart package will be handed off to the IT or infrastructures team and they will install it against the required Sharepoint system. It will work when activated.

8. An Error occurs in code after launch

What I would like to happen : An error will be either catastrophic or it will be fixed in the next version. If it is a catastrophic error, ie one that means people can’t use the application, a branched version will be developed to fix the issue, that branch will then be bought in line with the main code over the next full release version. Someone other than the development team decides if the error is catastrophic or not.

9. Working from home

What I would like to happen : I connect to my work network from home, I have all my current project code and intranet information available to me, without having to utilise remote desktop. I can interact with development systems as if I was at my work PC.

10. You pick up work for a different project

What I would like to happen : I can raise a flag that I have started work on this task, even if it currently ‘belongs’ to someone else. My time worked on this task will be recorded against it.

The next stage is to take “What I would like to happen” and turn it into “How to make it happen”. From that you can infer where you need new tools or processes and where you can start to improve the situation immediately.

That forms the basis of Part 3 of the article.

On.. Model View Presenter

As previously stated I’ve been using Model View Presenter as a design pattern in some form or other for over a year now. My understanding of how to implement it and the way I’ve used it have changed over the past year, but the fundamentals have remained the same. Recently I have been preaching the gospel of MVP to my co-workers, in fact I’ve written into our coding standards as our current best approach for application development. Whilst my previous MVP entry was aimed at those that understand the principle and want to implement it I am aiming this at those that want to learn what it’s all about.

A word of note, I’ll not be touching on Model View Controller, MVC.NET and any of its REST like abilities, because although they may be related in some abstract design way, implementations of MVP and MVC are different.

There are many good reasons to use MVP, testability, separation of layers, common application structure across different development streams, all of which have been documented and are part of the rise of interest in MVP. For me one of the main advantages about MVP is the way it separates it’s layers, it helps create a clear and focused design and development process. Even without the testability I find this reason enough to use MVP as my pattern of choice.

Like most patterns MVP is best represented by a diagram:

Model View Presenter Diagram

Click image to enlarge

Also like most patterns, the diagram can seem relatively impenetrable when you are first starting out trying to understand it. Whilst you can ramp up the complexity of your implementation quite quickly a basic understanding is a must. You can see in my previous post about a VB.Net MVP template an example of Hello World developed with the MVP pattern.

It is simpler to think of MVP in terms of separation of layers to begin with than it is to think of it in terms of calls and communications between classes. The following diagram shows the layer separation at work within my implementations of MVP:

My version of the diagram

MVP In Use

Click to enlarge

In effect it is a simple n-tier architecture. The View that implements the IView interface only cares about its properties and how it is displaying them. The Model only cares about its methods and how it is going to get the information requested of it. The Presenter only cares about your abstract logic and being the vessel for passing calls between the View and the Model. For database driven web applications the methods in the presenter can often just be the hooking up of a View property to a Model method to return the required data.

Once you have straightened out how the tiers work in MVP the next hurdle was what “knowledge” each of the parts have about each other. I’ve done this in a cascading manner, the View instantiates a Presenter, the Presenter is passed the View, when it is instantiated, and in turn instantiates the Model. The Model handles data access through helper classes and business objects. So the View only knows what Presenter it’s using, the Presenter only knows it has a View and a Model, the Model doesn’t know where its data is going to, but knows how to get it. In this way every part of the code is essentially hot swappable in a modular manner. We can completely rework the entire Model and never have to worry about changing anything in the View, and vice versa.

That’s the theory anyway.

My actual implemention, or: How I develop software.

Whilst the Pattern of MVP is relatively well defined actual implementations may vary. This is how I implement Model View Presenter.

My View interface will usually consist of a series of properties that I will have indirectly bound to controls. To establish my view I sit down with a pen and paper and work out my UI elements, text entry boxes, lists, comboboxes and whatever else might make up your particular interface. From there it is a case of working out what type of property they will be, if something will always be a number I’ll define it as an integer, otherwise it usually ends up as a string or a collection, I have recently been moving away from Datasets towards using collections.

During the design phase of my project I will sit down and work out what my program actually does. Most database back ended applications tend to have insert, update and delete, with a few other bits and pieces thrown in. For my Skimmp3 application I have a bit of paper that says “Get all the links on a website that are mp3s, download all mp3s from a website” and that is all. These inform me of what my model level should be doing. I can infer my methods from these lists of What does my program do?

For my own projects I will also define my business objects, what will be passing through my program? What will I have collections of? Sometimes the things that have fallen out of “What does my program do?” will work better at an object level, for example “Save Settings”, you may have a settings object that you put the Save() method in, it seems more sensible to put it with object than in the model.

At this point I’ll usually start bashing away at code. First defining my objects, then defining my model interface, I’ll implement the interface in the model class and then fill in skeleton functionality.

I then like to return to my View and implement an interface, whilst hooking up the form (windows or web) controls to the properties of the View.

This then leaves me to wire it all up with the presenter. In theory at this point it will all compile, but not actually do very much. By fleshing out the Model the full application starts to take shape.

If anyone wants a bit more detail on my development process drop me a comment and I’ll write an entry about it, I’m sure it’s not revolutionary, but it seems to work.


I’ve found two main problems with MVP as a pattern.

Starting out can be problematic, particularly if you have traditionally put the majority of your code directly in your code behind with the occasional data access class. MVP seems a cumbersome way to achieve something that you can achieve with fewer classes. It also a little confusing to set up for the first time, where to create objects and in the case of ASP.NET applications when to create them. All I can say to this is give it a go on a couple of small projects to get used to it. It really is one of those times when doing rather than talking gets you somewhere. Just don’t be put off by the first time, it can be tricky to begin with. I’ve started out with my VB.NET template when instructing other people how to build MVP applications by keeping everything in one project. Once the pattern is successfully understood then moving the Presenter and Model out to separate projects isn’t a huge leap. The most useful aspect of the Template I think is learning when and where to instantiate the Presenter and the Model. My first few attempts at doing MVP resulted in a lot of null reference exceptions!

The second issues I’ve found is events. This is mainly a problem for ASP.NET and the page lifecycle, if you are triggering events at the model level and passing the values back by the time it hits the view it can require a bit of thinking about when objects exist and when events are raised at the model level if those objects will still exist. It is a little more straight forward with windows forms although it still requires a reasonable amount of thinking through when considering the flow of information and event handling.

I hope this has been useful. If you have any questions I’ll do my best to answer them. I’ve helped a number of people get started on MVP and have written a number of real world projects myself using the pattern, so I should be able to help. Good luck with your implementations…

On.. Development Nirvana (part 1)

It seems there is a lot of talk.  The internet is full of it.  In the development community a lot of this talk is about easy, better, more fun, more innovative, more efficient, more impressive ways to develop.  The things is there is so much of this stuff that it is difficult to know what to, what to aim for.

So I’m going to attempt to work out what would currently be development nirvana for me and the team I work with.  Then ladies and gentlemen, I’m going to work out how to make it happen, rather than just talk about it.

The Constants

Okay here are my constants :

Team of about 6 developers
Multiple projects
.NET Based, developing in Visual Studio 2005
SQL Server
Sharepoint as major platform for deployment

These are things that we can assume won’t change, at least they won’t change for a good few months.

The Variables

When looking at what we have in place now here are the things that need changing:

Currently using Visual Sourcesafe for some projects, but not all
No Coding standards (although we have talked about them)
No Consistent deployment method (although we have talked about it)
About to start implementing more agile processes (worklogs, sprints etc.) (after talking about it for a long time)

The Approach

So there we have the boundaries in which we have to work.  Now, like a good programmer might, I need to optimise the environment in order to make it efficient at doing its job.  For me development nirvana can be summed up in one sentence; Nothing getting in the way.  That is the aim.  What principles can we apply to make this happen.

I’m going to take a tip out of Paul (our project managers) book and do some user stories of what I would like to happen in certain scenarios.  This is my starting list, I shall have to write the story of what I want to happen for each :

1.  Working for the first time on an existing project
2.  New project starts up
3.  Project finishes
4.  Team working on same application
5.  Error occurs in code during development
6.  New application needs to be deployed
7.  New Webpart needs to be deployed
8.  An Error occurs in code after launch
9.  Working from home
10. You pick up work for a different project

I will keep referring back to and updating this list, for the time being though these are the things that I would like to be as painless as possible.  I’ll attempt to tackle each one in turn, however I suspect that solutions for one thing may well provide solutions for another, or in some cases create new pain and new problems.

The act of simply listing the things I would like to be able to do smoothly has stimulated thought and created boundaries within which to make my own working day a lot easier and more fruitful.  Maybe you can give it a shot too, write ten things that you do regularly, then for each one see if there is a more efficient or better way of doing it.

On.. MVP Implementation and Project Template

I’ve been implementing Model View Presenter as a pattern for the best part of the last year in a range of projects. I think I’ve got a good handle on working with it, at least all my implementations work and are easy to maintain. The way I’ve implemented it has evolved over the past year through reading more, putting it into practice and discussions with collegues.

A Quick Intro to MVP
Model View Presenter (MVP) is an attractive way of working because of the level of layer abstraction it exhibits and the testability of the layers, particularly useful if you are an ASP.NET developer. I like the clear separation of each layer and the fact that one need not know how the other layer is implementing the interface. More to the point, it doesn’t care.

The best diagram I’ve found of MVP was this one on Flickr. It also compares it with the Model View Controller pattern. I didn’t like the circular nature of communication with MVC, one of the advantages of MVP to me is that as you scale the system you can completely rewrite any one section of it without breaking it. For example you can move everything from the Model backwards (towards the database) into a web service, or into WCF. Alternatively your designers now want the front end to be Silverlight, so you modify your View implementation to be Silverlight, without touching another part of your code. More to the point if you did both of these things the only part of your application that would have knowledge of that would be the layer adjacent to it.

On to my implementation.

So here it is, The view of my solution explorer when I open up my new VB.NET MVP Web Application Template (download Here and follow this entry through).

MVP Solution once opened

Like all these templates its probably better to go through and rename everything as you wish, it takes a little longer in an MVP projects. On which note I’ll just add that working with interfaces and carrying function names all the way down through the layers can result in some slightly longer refactoring times, but its not that bad.

So the first problems I came across when implementing MVP was how to hook everything together. The Template does all that. I now work on the basis that the View only knows what Presenter it is using, the Presenter knows the View (because it gets passed to it) and the Model. The Model will know the Data Access Layer and other Helper classes.

Right lets create a Hello World web app with this MVP template. I’m going to get the String from the Model so you can see it passing through the system.

My interface for the View will have a property of Message As String, the interface for the Model will contain Function GetMessage() As String.

I drop a label (Label1) onto the Deafult.aspx which will be implementing IView1, I then add the following code to the Default.aspx.vb. :

    Public Property Message() As String Implements IView1.Message
            Return Label1.Text
        End Get
        Set(ByVal value As String)
            Label1.Text = value
        End Set
    End Property

One day I’ll work out how to get binding oriented programming working and then I’ll make Paul Stovell happy.

Next I’ll do Model1, to which I add

    Public Function GetMessage() As String Implements IModel1.GetMessage
        Return "Hello World"
    End Function

Now the next bit is where the magic happens baby. In the Presenter I add the following:

    Public Sub GetMessage()
        m_View.Message = m_Model.GetMessage
    End Sub

Now all that remains is to go back into our View/Default.aspx and tell it to use the presenter to get the message. I’ll do this in the page load event, but we could hook it up to a button click or whatever if we wished.

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    End Sub

Lets hope thats working for you, because it doesn’t get simpler than that. If you put a breakpoint on the m_Presenter.GetMessage() line you can step through the code and see how the layers are separated. In full applications I like to keep the Presenter layer for abstract and business logic, whilst the Model should be dealing with data and how its getting it. The Presenter should have no knowledge of where the actual data is coming from or how it is being transformed before it gets to it, it knows it wants a String, or whatever it is your function requires be returned, as long as it gets it, it is happy.

Lets do something silly. Lets add a Helper class that will return our string instead. Functionally this is the same as moving your datalayer from being SQL to Oracle or Access or Excel or a Web Service. I’m going to add a class called MessageFetcher.vb to the Helper folder. The entire class looks like this:

Public Class MessageFetcher
    Public Function GetsMeAMessage() As String
        Return "Hello World, from further away"
    End Function
End Class

I now change Model1 GetMessage() Function to read thusly :

    Public Function GetMessage() As String Implements IModel1.GetMessage
        Dim myFetcher As New MessageFetcher
        Return myFetcher.GetsMeAMessage
    End Function

Now it may seem trival, but that is a whole massive change when you are talking about large applications, a massive change that will only affect the Model layer. I could go further, I could fetch the message from a database. I could start passing down through the subs and functions values to tell it which message I wanted from the database. I could ship the whole model layer out to be a web service that fetched messages depending on which ID was sent to it and the View and most of the Presenter could would never have to be altered. would never have to be altered.

You can download the Template Here to get started with this stuff. Download it and follow through the entry and see it working, even if you don’t use it in the future at least you get a handle on what people are talking about.

If people want I can do a WinForms one and a C# one too. If they think they will find it useful. Just drop me a comment. Also any questions drop them in the comments.