Cor Ligthert said:
Where is a static class or a whatever class a natural design.
Where utility methods are required, for starters. Besides, you didn't
originaly limit yourself to static classes, but to all static
variables.
At that point, you're preventing patterns such as the singleton pattern
(which does have disadvantages, but is appropriate sometimes).
I don't know if you believe in the great Englisman Darwin, otherwise have a
look in the Bibble both is about natural design. A static class is never for
me a Natural design as is not any class.
What would you do with HttpUtility then, just as an example? All its
members are static, so it effectively could (and should) be a static
class. The fact that it's got a public constructor is a mistake,
basically.
How about the System.Math class?
Both you are writing "an extra field reference isn't going to bring your app
tubling down"
Actually, I never wrote that.
I cannot place the context of this message, is this something Nick has
stated in this thread.
You should know that I would be the last one who would write that, therefore
we have had to much discussions about by instance avoiding boxing. From
which I write forever that you should try to avoid that but not put to much
effort in that.
Again though - where the design naturally uses boxing, it's fine to use
boxing.
So I am curious in what context you place that sentence?
You said to avoid static members where you *can* avoid them. You almost
always *can* avoid them - which means that by your standards, they
should virtually never be used.
Here's an example. Consider the Encoding class and its ASCII property.
That *could* create a new instance of ASCIIEncoding each time, instead
of caching it in a static variable. So one *can* avoid using a static
variable - and according to your logic, one therefore *should* avoid
it. Now, how is creating an instance of ASCIIEncoding every time
Encoding.ASCII is used actually a *good* idea? Do you like having lots
of instances of classes which effectively have no state?
Now, if you didn't actually mean your statement to be as strong as it
was, you shouldn't have made it that way. I can only go by what you've
actually written...