Thank god for the Obsolete Attribute

1 minute read

I’ve had to revisit one of my first projects at work because of a meeting I am having with the administrators/users of the application this coming week.  Almost immediately I noticed that I had to do some heavy refactoring of the application as the code base was built too hastily and code is sprinkled everywhere without any rhyme or reason.  With the application being around 15,000 lines of C# and ASP.NET code I had to device a way to move methods around and tag the old code as no longer something that should be used.  This is where the Obsolete attribute is very useful.  What I am doing is moving the code that is currently inside of my model classes and moving them to their own Data Access Layer (DAL) object and making the appropriate changes.  I then use the obsolete attribute and then use compile the application.  I then use the warnings generated from the obsolete attribute to update the method calls to use the DAL object instead!

So far this has been very successful and I am slowly, but confidently making the code base much better and easier to extend/update as needed!

Leave a comment