User controls and rabbit-hole syndrome

User controls (.ascx files) are a great way of re-using chunks of HTML and logic, easing maintenance overheading and ensuring you don’t repeat yourself, but used poorly they have exactly the opposite effect and vastly overcomplicate applications.

Take this scenario; you open up an .aspx page to fix a reported bug, only to find only a set of references to .ascx files. Undeterred, you open the control you believe contains the offending code, only to find… more .ascx references! In a page I came across recently, not only were there multiple levels of nested user controls, but in some cases those controls were used only once in the entire application. As a general rule, if you’re not going to re-use it, don’t extract it out into a separate file.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: