471,342 Members | 1,826 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,342 software developers and data experts.

Static class vs provider class

What is the difference between a helper class and a provider class? I
have seen plenty of helper classes as static classes with only static
methods, but I have also recently seen a provider class that is also a
static class with static methods. What should be the difference between
them?

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #1
4 1629
On Jun 27, 11:25*am, Mike P <mike.p...@gmail.comwrote:
What is the difference between a helper class and a provider class? *I
have seen plenty of helper classes as static classes with only static
methods, but I have also recently seen a provider class that is also a
static class with static methods. *What should be the difference between
them?
Well, I haven't heard "provider class" used much as a term, but I'm
guess it acts as a static factory. In other words, it doesn't provide
any functionality other than giving an appropriate implementation of a
particular interface/abstract class which in turn *does* provide the
functionality.

What's your context?

Jon
Jun 27 '08 #2
Here are a couple of cut down examples of classes I have seen labelled
as 'provider' classes :

1)

public class SqlArticlesProvider : ArticlesProvider
{
/// <summary>
/// Returns a collection with all the categories
/// </summary>
public override List<CategoryDetailsGetCategories()
{
using (SqlConnection cn = new
SqlConnection(this.ConnectionString))
{
SqlCommand cmd = new
SqlCommand("tbh_Articles_GetCategories", cn);
cmd.CommandType = CommandType.StoredProcedure;
cn.Open();
return GetCategoryCollectionFromReader(ExecuteReader(cmd) );
}
}
....
}

2)

public static class CleanseJobProvider
{

/// <summary>
/// Returns an XmlDocument
/// </summary>
/// <param name="userName"></param>
/// <param name="password"></param>
/// <param name="jobID"></param>
/// <param name="userID"></param>
/// <returns></returns>
public static XmlDocument GetDefaultExtraction(string userName,
string password, int jobID, int userID)
{
slndat13.Integrator intergratorProxy = GetProxy(userName,
password);
object[] iresult =
intergratorProxy.DefaultEmptyExtraction(jobID, userID);
XmlDocument doc = new XmlDocument();
if (iresult[0] is DataSet)
{
if (((DataSet)iresult[0]).Tables.Count 0)
{
DataRow dr =
((DataSet)iresult[0]).Tables[0].Rows[0];
SqlXml sqlx = (SqlXml)dr[0];
if (!sqlx.IsNull)
{

//System.Diagnostics.Debug.WriteLine(sqlx.Value);
doc.LoadXml("<job>" + sqlx.Value + "</job>");
}
}
}
return doc;
}
...
}

*** Sent via Developersdex http://www.developersdex.com ***
Jun 27 '08 #3
On Jun 27, 12:03*pm, Mike P <mike.p...@gmail.comwrote:
Here are a couple of cut down examples of classes I have seen labelled
as 'provider' classes :

1)

public class SqlArticlesProvider : ArticlesProvider
Okay, so that's a normal kind of class, overriding a method.
public static class CleanseJobProvider
Hmm. That's not terribly clear, and I'd argue that it would make for
more testable code if it implemented an interface instead of being
static. That would allow dependency injection in the normal way.

Jon
Jun 27 '08 #4
Mike P wrote:
What is the difference between a helper class and a provider class? I
have seen plenty of helper classes as static classes with only static
methods, but I have also recently seen a provider class that is also a
static class with static methods. What should be the difference between
them?
To me a provider class is a class that provides an implementation
of a specific API (for those that also code in Java: think SPI).
Completely different from a helper class and never static.

Arne
Jun 29 '08 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

49 posts views Thread by bearophileHUGS | last post: by
8 posts views Thread by Steven Livingstone | last post: by
5 posts views Thread by TomislaW | last post: by
4 posts views Thread by Mantorok | last post: by
10 posts views Thread by Fred Mertz | last post: by
1 post views Thread by kownacek | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.