User Controls are useful because you can encapsulate the logic inside it and reuse the control more times in the web application.
I want to know if it is a good practice to increase the logic of a user control for using it more times in the web application or if it is better to duplicate the user control and change the logic in the new control to mantain the code esier to understand
for the developer.
So is it better to reuse the control more times and to have more logic complexity or is it better to duplicate the user control more times and having easier logic to understand?
it depends on your requirements. If you want to have a generic control it could become complex, but it will fit into more scenarios. If you want to have a control which is only created for one purpose (in a sense of reusability) you should keep it simple
(it only should do for what it is created and the rest should be handled anywhere else).
For the simple scenario: You can create a base control from which other controls (depending on their purpose) can inherit and add additionally complexety. That should be the best way if you follow an OOP design, reusability, and understanding.
Regards.
If my post solves your problem, please mark as answer.
Marked as answer by Simone75 on Feb 27, 2012 07:21 AM
Simone75
Member
71 Points
38 Posts
Question on good practice in user control design
Feb 23, 2012 04:00 PM|LINK
User Controls are useful because you can encapsulate the logic inside it and reuse the control more times in the web application.
I want to know if it is a good practice to increase the logic of a user control for using it more times in the web application or if it is better to duplicate the user control and change the logic in the new control to mantain the code esier to understand for the developer.
So is it better to reuse the control more times and to have more logic complexity or is it better to duplicate the user control more times and having easier logic to understand?
Thanks.
Simone
abhijeetmish...
Member
272 Points
95 Posts
Re: Question on good practice in user control design
Feb 23, 2012 04:38 PM|LINK
well there are two purpose of a user control:
1.) create a complex control which cannot be created using out of the box server controls.
2.) Reusability
The logic inside can be complex but should be dependent in any sense.
Thanks,
Abhi
Horizon_Net
Star
8277 Points
1435 Posts
Re: Question on good practice in user control design
Feb 23, 2012 05:21 PM|LINK
Hi Simone,
it depends on your requirements. If you want to have a generic control it could become complex, but it will fit into more scenarios. If you want to have a control which is only created for one purpose (in a sense of reusability) you should keep it simple (it only should do for what it is created and the rest should be handled anywhere else).
For the simple scenario: You can create a base control from which other controls (depending on their purpose) can inherit and add additionally complexety. That should be the best way if you follow an OOP design, reusability, and understanding.
If my post solves your problem, please mark as answer.