472,958 Members | 2,533 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 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 1681
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

49
by: bearophileHUGS | last post by:
Adding Optional Static Typing to Python looks like a quite complex thing, but useful too: http://www.artima.com/weblogs/viewpost.jsp?thread=85551 I have just a couple of notes: Boo...
8
by: Steven Livingstone | last post by:
Anyone able to explain to me why you cannot define an interface that can then be implemented using static methods? I understand the C# CLS states this, but just interested in the reasons behind...
9
by: Laban | last post by:
Hi, I find myself using static methods more than I probably should, so I am looking for some advice on a better approach. For example, I am writing an app that involves quite a bit of database...
5
by: TomislaW | last post by:
What is the purpose or difference between private static and private method in non-static class?
4
by: Mantorok | last post by:
Hi I have an ASP app which references a few static properties in some of the classes. I understand that you should use Session variables, but is it "possible" to have each session "not"...
15
by: Joe Fallon | last post by:
I would like to know how you can figure out how much memory a given instance of a class is using. For example, if I load a collection class with 10 items it might use 1KB, and if I load it with...
0
by: Alex Brown | last post by:
Is it a problem to attach Non-static site map providers under one that inherits from StaticSiteMapProvider ? We are implementing a custom site map provider for a website that is being converted...
10
by: Fred Mertz | last post by:
I'm wondering what some of the important considerations are regarding implementing the DAL as a static class vs creating instances of it as needed. I'm writing a .NET 2.0 Windows application...
1
by: kownacek | last post by:
Hello. I have some classes which resemble tables in a database. I'd like to create CRUD-like methods for each class, for example Create(), GetAll(), GetById(Guid id), DeleteById(Guid id), etc......
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.