PC Review


Reply
Thread Tools Rate Thread

Base page VS Utility Class

 
 
Jeff User
Guest
Posts: n/a
 
      11th Feb 2007
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
 
Reply With Quote
 
 
 
 
=?ISO-8859-1?Q?G=F6ran_Andersson?=
Guest
Posts: n/a
 
      11th Feb 2007
Jeff User wrote:
> 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.

--
Göran Andersson
_____
http://www.guffa.com
 
Reply With Quote
 
Ollie Riches
Guest
Posts: n/a
 
      12th Feb 2007
check out the visitor pattern

http://en.wikipedia.org/wiki/Visitor_pattern

Ollie Riches

"Jeff User" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
PS
Guest
Posts: n/a
 
      13th Feb 2007

"Jeff User" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
Jeff User
Guest
Posts: n/a
 
      16th Feb 2007
Thanks everyone for all the good advice

Jeff

On Sun, 11 Feb 2007 13:25:10 -0500, Jeff User <(E-Mail Removed)>
wrote:

>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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl). murl Microsoft ASP .NET 0 27th Mar 2007 10:30 PM
how to make sure this.Test() call base class method in base class constructor Ryan Liu Microsoft C# .NET 2 27th Aug 2006 07:43 PM
reference master page class from content page base class? Managed Code Microsoft ASP .NET 3 31st Jul 2006 05:39 PM
Custom Page Class - Parse Controls? Chain to Base Page? Jeremy Microsoft ASP .NET 0 23rd Jun 2004 04:32 PM
variable type that can be declared in a base class this is accessible only to classes that inherit the base class Dan Microsoft ASP .NET 1 24th Mar 2004 09:34 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:10 AM.