Friday, September 20, 2024

Refactoring Your ASP.NET Project

One day at work i was refactoring my code as I do everyday, when it suddenly hit me that our ASP.NET projects were also refactored in a sense.

For those of you who don’t know what refactoring is, here’s a definition.

“Refactoring is making changes to a body of code in order to improve its internal structure, without changing its external behavior”.

In layman’s terms it means the process of cleaning your code and break it up in smaller more maintainable pieces.

It’s a discipline most programmers are accustomed to and have been using for years no matter the programming language or platform.

The principle of refactoring should also be upheld when designing the structure of your ASP.NET projects. This is typically done by moving code to user controls for reuse and maintainability.

However, there is a big difference in refactoring a C# class library and the ASP.NET pages/controls.

Whereas refactoring is an ongoing process in a class library type of situation, it is more a static one in the ASP.NET scenario or much more difficult to do.

For instance, if you want to move a region of a page to a user control, you have to move the little individual pieces as well. The list of things to move usually contains the HTML, JavaScript, image references and the C#/VB.NET logic.

That’s a whole lot more than you would do in a class library situation and that’s why you have to do a lot of planning before you create your ASP.NET architecture.

That kind of architecture is very important because of the difficult refactoring process in ASP.NET, and that’s why you should plan ahead before you start writing your pages and user controls.

It’s a tough job to correct when your project grows bigger and more complex and projects tend to do just that.

I know refactoring isn’t the same as designing the structure, but it’s probably the closest thing we can get to refactoring ASP.NET pages and user controls.

Tag:

Add to Del.icio.us | Digg | Reddit | Furl

Bookmark Murdok:

Mads Kristensen currently works as a Senior Developer at Traceworks located
in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in
2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and
web services in his daily work as well. A true .NET developer with great passion for the simple solution.

Home

Previous article
Next article

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles