Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should functionality that's only used once go in a UserControl?

Forgive me if this is a slight mis-use of the system, but I'd like fellow StackOverflow users to settle a debate a colleague and I are having.

As a general rule, I prefer each separate item of functionality to be encapsulated within a UserControl even if I know it's only going to be used once.

My colleage will eschew creating a UserControl in this circumstance and use a WebForm, arguing that if it's only going to be used once, what's the point of creating a UserControl - it just adds an additional, unnecessary overhead.

I argue that the additional overhead is negligible and it makes for better-organised code, and who knows, you may re-use the functionality at some point in the future.

So who's right?

Edit

It looks like I may get quite a few responses - my colleague and I have agreed that we'll count up the replies in a day and award the correct answer to whichever argument gets the most votes.

Further edit

Looks like I'm the winner :D

I've ignored posts that suggest we're both right, and counted an answer in support of each side as +1, and each up-vote on that answer as a +1 too. I win 11-6.

like image 462
Paul Suart Avatar asked Dec 02 '22 08:12

Paul Suart


1 Answers

If it makes the code better organized, I'll always try to create separate user controls.

This really makes communication easier to follow. Think SRP.

like image 71
Lennaert Avatar answered Feb 19 '23 12:02

Lennaert