As you might have noticed from my recent posts, I’ve just recently jumped from one platform to another. And my current project is a bit of a legacy thing. A lot of people worked on it previously and those who did weren’t necessarily experts in the technology that they used when they initially developed it. They did a lot of hacky things, to get things going. But such hacks are good for getting a product moving, but not really good for maintaining them. And now that I’m having to implement changes to them, I realized how hard they have made this for me.
Often in software development we think that we can solve a problem easily by special casing a certain scenario and the rest can go on as usual. And this is your enemy. Avoid it at all costs unless you are going to leave your current firm soon after implementing that. But even then I wouldn’t ask you to do it that way. I would still feel sorry for the person who would take charge after you.
I’m now in the process of refactoring a lot of such code. There is lots to do, but I have a project to get done. But I’m more of a long term person when it comes to software engineering. I wouldn’t want to put a dirty solution in place, unless there is a good reason for it to be, like if it was a hackathon or something.
Even though many of you might feel that refactoring is a pain and is not fun, I think it is not bad after all, especially since I’m new the platform. It is kind of like, reading Effective C# from other peoples bad practices, instead of actually going through the book. And sometimes it is not always bad practices. It might be good things that point in time, but there have been a lot of new stuff in terms of programming paradigms that came up after they left the code. Like now one of my goals is to replace all references to stored procedures in the project code to LINQ and Entity Framework. Not easy and can’t be done in one go, but it will be something that I’ll have to do every time I hit a part of the code that touches a stored procedure. Not so surprisingly, there are lots of references to stored procedures. And there are a lot of new stuff written recently using Entity Framework. I would like to stick to one, rather than a mix of both and make things more complicated.
And when refactoring I actually tweeted what was in my mind, embedding tweet below.
It is indeed a learning experience. I only wish I had all that time.