views:

191

answers:

12

Whats is the ideal class name for my static class which has some static methods to handle General/Common functionalities iike taking backup,saving recent items etxc.. (Infact Misc items ) in C#. I would like to have Manager as suffix of the class name (ex: SaleManager(to handle sales related functionalities),ContatManager(to handle contact related functionality)

A: 

UtilityManager..?

Chris
+2  A: 

It turns out that "Utility" is controversial, while "Math" is not. So it would seem that the name should suggest the overall functionality of the methods in the static class.

Robert Harvey
+3  A: 

My general feeling is that one should not have such a general class. Email in particular is quite likely to expand to more than just a SendEmail() method and frankly new Email({to, subject, body}).Send() makes a lot more OO sense.

annakata
yes .for this example only i mentioned like that,Removing that from the question now
Shyju
A: 

There are very good reasons not to do that kind of thing. It is considered an anti-pattern.

Martinho Fernandes
+11  A: 

RefactorMeManager.

Mathias
+1 Brilliant answer that makes the OP think ;-)
Marc Wittke
+1 It answers the question with "DON'T" in big bold letters, yet it doesn't hurt your eyes.
Martinho Fernandes
-1 Humorous, but not particularly enlightening
Robert Harvey
@Robert - Not enlightening? I would say it was zen.
annakata
A: 

Even for static classes (btw: I prefer the XxxHelper suffix) I'd stick to the paradigm "Separation of Concerns" and would not mix different utilities in one class.

Marc Wittke
+2  A: 

Here are some .NET Framework classes that perform these types of operations:

  • System.Environment
  • System.Math
  • System.IO.File
  • System.IO.Directory
  • System.IO.Path
  • System.Runtime.InteropServices.Marshal

As you can see, the routines are grouped by topic into classes, and none of the classes have "Helper" or "Utilities" appended. Here are some classes I've made that perform some of these types of things:

  • SymbolicMath (like the Math class, but for working with symbolic math expressions)
  • BigIntegerMath (library of large-integer arithmetic using System.Numerics.BigInteger type - primality proving, factoring, and some other things)
280Z28
A: 

The God object!

Simon Svensson
Actually, that doesn't really fit the definition of a God object.
shoosh
+1  A: 

If you have a Utility (or UtilityManager) class that has lots and lots of static methods, that is indeed an anti-pattern and should be refactored pronto.

However, there are the things that are just that - utilities, and one should not refrain from putting them in a separate Utilities class (my personal favourite). Yes, that opens the door for all sorts of ugly scenarios, and one has to hold the reins, or anything and everything will end up there, and yes, there is a need to "promote" methods to their own class (usually XXXHelper) if the need arises, but, nonetheless, I find the Utilities class a helpful construct, and not an anti-pattern by itself. Patterns are a recommendation after all, they are not a religion :)

Manager as a suffix for that kind of a class is confusing, because the class does not in fact manage anything.

SWeko
+1  A: 

Tools
Utils
Extensions (if you put just extension methods in there (C#))

Omu
A: 

public class DataHandler

A: 

Long live internal static class Utils.

Mau