App_Code Class Help: good practice

S

sck10

Hello,

I created a class (public class General) with the following. My question
is, is this good practice to have a group of methods(?) in one class, or
should I have a separate class for each method? I'm not sure if this makes
sense, but can/should you put more than one class in a file (myclasses.cs)?
Any help would be appreciated...

Thanks, sck10


public class General
{

public void HidePanels(Page MyPage)
{
// my code
}

public void SetFocusControl(Control FocusControl)
{
// my code
}

public string ClearCell(object RepeaterValue, string CompareValue)
{
// my code
}

protected void SendMail(string From, string To, string Subject, string Body,
string Client)
{
// my code
}

}
 
S

Steven Cheng[MSFT]

Hello Steve,

Since the class in your case is a small helper class specific to the
ASP.NET application(you put it in App_Code directory), you can simply put
those methods within one class. Also, using mutiple classes to group
methods of different categories should be a good practice, for your
scenario, you can group those helper methods which perform control
collection manipulation into a single class.. And of course, you can put
multiple classes in single code file if they have the similar functions.

If you want to design some formal and reusable class library components,
you can consider following some more detailed coding and designing
guideline and best practices. Here is a web article on C# coding style
guide:

#C# Coding Style Guide
http://www.csharpfriends.com/Articles/getArticle.aspx?articleID=336

BTW, if you have interests, you can have a look at the following book which
is recommended by many developers for .net class library and framework
designing(I've bought one myself :)):

#Framework Design Guidelines
http://www.amazon.com/gp/product/0321246756/103-5289819-9757452?v=glance&n=2
83155

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

sck10

Thanks Steven,

Appreciate the info and I'll have to check out the book you recommended...
 

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