473,804 Members | 1,992 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1708
On Jun 27, 11:25*am, Mike P <mike.p...@gmai l.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 SqlArticlesProv ider : ArticlesProvide r
{
/// <summary>
/// Returns a collection with all the categories
/// </summary>
public override List<CategoryDe tailsGetCategor ies()
{
using (SqlConnection cn = new
SqlConnection(t his.ConnectionS tring))
{
SqlCommand cmd = new
SqlCommand("tbh _Articles_GetCa tegories", cn);
cmd.CommandType = CommandType.Sto redProcedure;
cn.Open();
return GetCategoryColl ectionFromReade r(ExecuteReader (cmd));
}
}
....
}

2)

public static class CleanseJobProvi der
{

/// <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 GetDefaultExtra ction(string userName,
string password, int jobID, int userID)
{
slndat13.Integr ator intergratorProx y = GetProxy(userNa me,
password);
object[] iresult =
intergratorProx y.DefaultEmptyE xtraction(jobID , userID);
XmlDocument doc = new XmlDocument();
if (iresult[0] is DataSet)
{
if (((DataSet)ires ult[0]).Tables.Count 0)
{
DataRow dr =
((DataSet)iresu lt[0]).Tables[0].Rows[0];
SqlXml sqlx = (SqlXml)dr[0];
if (!sqlx.IsNull)
{

//System.Diagnost ics.Debug.Write Line(sqlx.Value );
doc.LoadXml("<j ob>" + 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...@gmai l.comwrote:
Here are a couple of cut down examples of classes I have seen labelled
as 'provider' classes :

1)

public class SqlArticlesProv ider : ArticlesProvide r
Okay, so that's a normal kind of class, overriding a method.
public static class CleanseJobProvi der
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
3130
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 (http://boo.codehaus.org/) is a different language, but I like its "as" instead of ":" and "->", to have: def min(a as iterable(T)) as T: Instead of:
8
52759
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 it. thanks, Steven
9
2666
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 operations on purchase orders and inventory. I have created a PurchaseOrder class and Inventory class to encapsulate operations like creating POs, finding items, etc. These two classes are used extensively from different parts of the app.
5
1659
by: TomislaW | last post by:
What is the purpose or difference between private static and private method in non-static class?
4
2488
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" reference the same static members. For example if I update the static member on one session this change will be reflected on somebody elses session, which I don't want. I hope there's an easy solution for this as changing to session variables
15
2422
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 1000 items it might use 100KB. How do I measure the amount of memory used once the class is loaded? Thanks! -- Joe Fallon
0
2138
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 to ASP.NET 2.0. The conversion is going well because some of the features, like Master Pages and Site Maps, of ASP.NET 2.0 allow us to migrate away from a "top frame" style of navigation to a standard dynamic cascading top menu with minimal...
10
9098
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 (MDI) that will communicate with a SQL Server; approximately 120 users. On smaller apps I have tended to implement the DAL as a static class. But this new app will likely spawn background threads periodically to update business objects throughout...
1
279
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... I can implement an interface to force Create() for example, but GetAll() should return a list/array of object and it should be static. I cannot make static methods in an interface in C#.
0
9711
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10088
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9169
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6862
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5529
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5668
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.