Why is my location on the world map determined incorrectly?
Instance vs Static + Option
Hello Guest
  
  • Login
• Register…
• Start blog
  • Who, Where, When
• What can I do?
• What to Read?
  • Polls
• Avatars
• Interests
  • Cities and Countries
• Random blog
• Users search
  • Search
• Games
• Tests
• QAIX
  • Сообщества
• Talxy Chat
• Horoscope
• Online
 
Зарегистрируйся!

QAIX > .Net Development > Instance vs Static + Option 17 May 2008 23:57:33

  Recent blog posts: 
  They have birthday today: 
  Forums:   
  Discuss: 
  Recent forum topics: 
  Recent forum comments:
  Moderators:

Instance vs Static + Option

Brady Kelly 17 May 2008 23:57:33
 I am busy with a new ConfigHelper class, and can't seem to decide on which
approach to take. The class is responsible for adjusting the config table
in two databases, control and test. My dilemma is whether I make
ConfigHelper a static class, and tell it which database to access for each
task, or use instance methods and have one instance for each database.


===================­================
This list is hosted by DevelopMentor http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Davy J 9 May 2008 14:06:38 permanent link ]
 I've been using a proxy pattern for stuff like this, I tried using
Spring.Net to do it, but what a nightmare to configure for just one or
two objects.
here's a quick and dirty example
hth. Davy J


public interface ISettings
{
object ReadValue(string name);
void WriteValue(string name, object value);

}

/// <summary>
/// Public class that is used to read the settings from, not there
is no real implementation in this class
/// it serves as a proxy class.
/// </summary>
public class Settings : ISettings
{
private ISettings proxy;
#region ISettings Members

private void CheckProxy()
{
if (proxy == null)
{
switch (Properties.Setting­s.Default.CodeVersio­n)
{
case "DEBUG":
this.proxy = new TestSettings();
return;
default:
this.proxy = new LiveSettings();
return;
}

}
}
public object ReadValue(string name)
{
CheckProxy();
return proxy.ReadValue(nam­e);
}

public void WriteValue(string name, object value)
{
CheckProxy();
proxy.WriteValue(na­me,object);
}

#endregion
}

/// <summary>
/// Application class.
/// </summary>
public class DemoClass
{
//We create a new class and don't worry about what we will be attacking.
private Settings settings = new Settings();
private string connectionString = string.Empty;
public DemoClass()
{
//We get a connection string from the class.
connectionString = (string)settings.Re­adValue("ConnectionS­tring");
}
}

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Peter Obiefuna 9 May 2008 18:44:03 permanent link ]
 I would write one static helper class and pass the control/test value as a
parameter.


public static string SayHello(string message, Environment environment){
if (environment == Environment.Control­){
return string.Format("Hell­o {0} from Control", message);
}
return string.Format("Hell­o {0} from Test", message);
}

-------------------­--------------------­-----------
From: "Brady Kelly" <brady@CHASESOFTWAR­E.CO.ZA>
Sent: Wednesday, May 07, 2008 6:39 AM
To: <DOTNET-CLR@DISCUSS­.DEVELOP.COM>
Subject: [DOTNET-CLR] Instance vs Static + Option

I am busy with a new ConfigHelper class, and can't seem to decide on which
approach to take. The class is responsible for adjusting the config table
in two databases, control and test. My dilemma is whether I make
ConfigHelper a static class, and tell it which database to access for each
task, or use instance methods and have one instance for each database.
===================­================
This list is hosted by DevelopMentor® http://www.develop.­com
View archives and manage your subscription(s) at

===================­================
This list is hosted by DevelopMentor® http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Nick Robinson 16 May 2008 23:38:14 permanent link ]
 There isnt enough context to go off, but I would personally prefer an instance over statics. I have found that as soon as I even hint at the word "helper" it polarizes my subsequent thoughts on how to design something. Rarely in my experience do I see a helper without statics (a recent project was more helper than anything else), so as soon as I use the term, I immediately think it will probably have statics.

Nick.

-----Original Message-----
From: brady@chasesoftware­.co.za
Sent: Wed, 7 May 2008 14:39:36 +0200
To: dotnet-clr@discuss.­develop.com
Subject: [DOTNET-CLR] Instance vs Static + Option
I am busy with a new ConfigHelper class, and can't seem to decide on
which
approach to take. The class is responsible for adjusting the config
table
in two databases, control and test. My dilemma is whether I make
ConfigHelper a static class, and tell it which database to access for
each
task, or use instance methods and have one instance for each database.
===================­================
This list is hosted by DevelopMentor. http://www.develop.­com
View archives and manage your subscription(s) at

===================­================
This list is hosted by DevelopMentor http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Brady Kelly 17 May 2008 13:35:58 permanent link ]
 
There isnt enough context to go off, but I would personally prefer an
instance over statics. I have found that as soon as I even hint at the
word "helper" it polarizes my subsequent thoughts on how to design
something. Rarely in my experience do I see a helper without statics
(a recent project was more helper than anything else), so as soon as I
use the term, I immediately think it will probably have statics.
Nick.

Maybe Provider would me more apt than helper then. Provider sounds more
dedicated.

===================­================
This list is hosted by DevelopMentor http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Nick Robinson 17 May 2008 17:20:38 permanent link ]
 You mean something like ConfigProvider? Does this class provide CRUD style behaviour onto a "config table", or does it do something very specific with a config table? I dont know whether Provider is the right term, but the fact it makes the class feel more dedicated is good. Of course, it could still be a helper, and thats ok.

Nick.

-----Original Message-----
From: brady@chasesoftware­.co.za
Sent: Sat, 17 May 2008 11:35:58 +0200
To: dotnet-clr@discuss.­develop.com
Subject: Re: [DOTNET-CLR] Instance vs Static + Option
There isnt enough context to go off, but I would personally prefer an
instance over statics. I have found that as soon as I even hint at the
word "helper" it polarizes my subsequent thoughts on how to design
something. Rarely in my experience do I see a helper without statics
(a recent project was more helper than anything else), so as soon as I
use the term, I immediately think it will probably have statics.
Nick.
Maybe Provider would me more apt than helper then. Provider sounds more
dedicated.
===================­================
This list is hosted by DevelopMentor. http://www.develop.­com
View archives and manage your subscription(s) at

___________________­____________________­____________________­_
Receive Notifications of Incoming Messages
Easily monitor multiple email accounts & access them with a click.
Visit http://www.inbox.co­m/notifier and check it out!

===================­================
This list is hosted by DevelopMentor http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Brady Kelly 17 May 2008 17:42:43 permanent link ]
 
You mean something like ConfigProvider? Does this class provide CRUD
style behaviour onto a "config table", or does it do something very
specific with a config table? I dont know whether Provider is the right
term, but the fact it makes the class feel more dedicated is good. Of
course, it could still be a helper, and thats ok.
Nick.

It provides an application layer maybe one up from CRUD, where it performs
sets of CRUD operations on a config table, and other operations, as required
for certain tasks. E.g. If I call SetAccountingPackag­e, it may set fields
in the config table to select that accounting package, create an export
directory for that accounting package, and set another field in the table to
point to that directory.

===================­================
This list is hosted by DevelopMentor http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
Nick Robinson 17 May 2008 23:57:33 permanent link ]
 Right, that sounds like a lot of important behaviour, so back to the original question about Helper, that role feels like you lose an important class.

-----Original Message-----
From: brady@chasesoftware­.co.za
Sent: Sat, 17 May 2008 15:42:43 +0200
To: dotnet-clr@discuss.­develop.com
Subject: Re: [DOTNET-CLR] Instance vs Static + Option
You mean something like ConfigProvider? Does this class provide CRUD
style behaviour onto a "config table", or does it do something very
specific with a config table? I dont know whether Provider is the right
term, but the fact it makes the class feel more dedicated is good. Of
course, it could still be a helper, and thats ok.
Nick.
It provides an application layer maybe one up from CRUD, where it
performs
sets of CRUD operations on a config table, and other operations, as
required
for certain tasks. E.g. If I call SetAccountingPackag­e, it may set
fields
in the config table to select that accounting package, create an export
directory for that accounting package, and set another field in the table
to
point to that directory.
===================­================
This list is hosted by DevelopMentor. http://www.develop.­com
View archives and manage your subscription(s) at

===================­================
This list is hosted by DevelopMentor http://www.develop.­com

View archives and manage your subscription(s) at http://discuss.deve­lop.com

Add comment
 

Add new comment

As:
Login:  Password:  
 
 
  
 
Пожалуйста, относитесь к собеседникам уважительно, не используйте нецензурные слова, не злоупотребляйте заглавными буквами, не публикуйте рекламу и объявления о купле/продаже, а также материалы нарушающие сетевой этикет или УК РФ.


QAIX > .Net Development > Instance vs Static + Option 17 May 2008 23:57:33

see also:
[JBoss Portal] - Using JBoss Portal 2.4…
[Beginners Corner] - Why I can run…
[JNDI/Naming/Network] - Re…
пройди тесты:
What is Your Temperament?
see also:
E-Cracker 10.0 ***Finally Released!***
E-Cracker 11.0 pro edition ||||||||…
All recruitment agencys come here!

  Copyright © 2001—2008 QAIX
Idea: Miсhael Monashev
Помощь и задать вопросы можно в сообществе support.qaix.com.
Сообщения об ошибках оставляем в сообществе bugs.qaix.com.
Предложения и комментарии пишем в сообществе suggest.qaix.com.
Информация для родителей.
Write us at:
If you would like to report an abuse of our service, such as a spam message, please .