I have to write large amount of code which is going to be used in three asp.net pages.
I want to know the key points so that I can decide whether I should create Static Helper class , or create base class for common codes.
I am agree that creating single helper class vs creating multiple helper classes must be a careful job depending on various things like performance etc.., but the question still remain same , you can think me as a smart coder that can create perfect number of helper classes.
I think I am going to use these code only from these three asp.net pages.
Thanks for all your answers friends, but I need more inputs, can you please send more specific points.
Thanks.
If it is code that is being shared by all three ASP.NET pages and not by other code, a baseclass is a good idea.
The code is not exposed to the 'outside world' (by making the methods protected) and you define a context in which the methods should be used. They can only be called from an ASPX page that defines trough inheritance that it is-a certain base type where the methods make sense. A Helper method could be called from everywhere in your code by just passing the right parameters, even if this is conceptual invalid.
If it's code that's going to be called from different places (for example a ValidateEmail function) then a static helper class could help.
But if you opt for the helper class, you still have to decide how many helper classes you are going to create. Dumping all your helper functions in one class is probably not a good idea from maintenance perspective.
Create a base page and inherit from that and then put your helper method and properties on the base page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With