473,396 Members | 1,777 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 1693
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.