Base page VS Utility Class

J

Jeff User

Hi all

Developing C# web apps, .net1.1

I have gotten in habit of placing commonly used (interface) functions
in my base page. However, some apps I work on use a seperate "Utility"
class containing common utility functions.

Is there any benefit in doing it one way or the other?
For instance, does having to load up a seperate class cost more or
less than loading a base page?

Best practices / thoughts are wanted.

Thanks
Jeff
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Jeff said:
Hi all

Developing C# web apps, .net1.1

I have gotten in habit of placing commonly used (interface) functions
in my base page. However, some apps I work on use a seperate "Utility"
class containing common utility functions.

Is there any benefit in doing it one way or the other?
For instance, does having to load up a seperate class cost more or
less than loading a base page?

Best practices / thoughts are wanted.

Thanks
Jeff

The cost of course depends on what the constructor does in each case.
The actual creation of the object costs very little.
 
P

PS

Jeff User said:
Hi all

Developing C# web apps, .net1.1

I have gotten in habit of placing commonly used (interface) functions
in my base page. However, some apps I work on use a seperate "Utility"
class containing common utility functions.

Is there any benefit in doing it one way or the other?
For instance, does having to load up a seperate class cost more or
less than loading a base page?

Best practices / thoughts are wanted.

2 best practices are

1) avoiding code duplication
2) avoiding a bloated base class

When you find that 2 base classes have identical methods then you can
extract this out to a common utility class. You can still keep your method
in the base class if you want but it does nothing but use the utility class.
The advantage of this is that it is easy to know what methods are available
for your class however this also tends to bloat your base classes with many
methods.

Most people use the code smell principle. When it smells a little off then
it probably is and you refactor.

PS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top