Admitting that your baby's ugly

| 0 Comments

I have a couple of days to myself. We've just shipped some code to a client a couple of days ahead of schedule and we're waiting to recieve a purchase order from another client so I find myself without any client work to do. I've decided to try and refactor The Server Framework code that we're using a lot right now. Whilst working on the code that we've just shipped I realised that the new code I was writing was much easier to test than the socket server library that formed a major part of the project, so now that I have some time I'm going to try and rectify that. The problem is, it means facing up to some unfortunate facts...

The socket server code has had a much longer and more reusable life than we initially expected. We first wrote the code as part of a project for a client back in early 2002. We decided that the code would be more useful to us if it was a little more reusable so we cleaned it up and wrote about it on CodeProject. This led to further clients that wanted projects based on the codebase and, well, requirements changed and the thing grew. We added filtering, encryption and SSL support and produced UDP and AcceptEx versions of the code for various clients and wrote shims so that a client who originally bet the farm on the NDK framework could replace it for performance and stability reasons without changing any of their dependant code.

The result is code that's been pulled and pushed in all manner of directions that were never imagined during the original design stage. It still works, but it's more complex than it needs to be and it's hard to test...

Sometimes you get too attached to some code, because of the attachment you excuse problems that you would normally complain about and fix... It's time to take the socket server code apart and rebuild it. The code is poorly factored in places, the coupling is too tight and (I think I've said this before) it's too hard to test...

The good news is that I have lots of code that's dependant on this code and all of the servers have test harnesses that test the servers as a black box. So I am comfortable that I have a good test suite. The bad news is that I have lots of code that's dependant on this code...

Leave a comment