Re: Static Classes ... in response to B. Voigt's comments
- From: "Bill Woodruff" <billw@xxxxxxxxxxxxxx>
- Date: Tue, 25 Mar 2008 11:16:47 +0700
Peter Duniho wrote : "... However, as far as your question goes, it seems to
me that one obvious difference between a static class and the singleton
pattern is that a singleton, being an instanced object, can implement
interfaces and inherit other classes.
The two share a lot in common, I'll grant. But I don't think that a static
class is inherently a singleton itself."
Some good points there to think on, Peter. Appreciated. One thought that
occurs to me is to wonder (I guess I'll have to go back to the "epiphany" as
revealed by the Gang of Four to check on it) if the "original" concept of a
Singleton had any reference to Interfaces or Inheritance. But that could
just turn out to be a pedantic quest. Me like Interfaces, Rhino or no Rhino.
The thought also comes that most of us writing WinForms applications make
use of a Static class, Program.cs, every time we use the default WinForms
app template to start a new project :) Of course that's not a Singleton
since you can run multiple copies of the .exe. I've seen a variety of ways
to make sure one-and-only-one instance of your app runs.
So maybe I should be careful to distinguish between Singleton as a pattern
that enforces one-and-one-only of some object, and "Singleton" as a method
of having a single-instance-at-a-time-running in the context of WinForms
apps ?
Interfaces, as contracts that enforce, appeal to me but I keep sometimes
wondering why there isn't an Interface "flavour" that specifies the scoping
of what it requires you code : i.e., that says, in effect : "when you
inherit from this Interface, you must implement this as static, this as
public, and this as private readonly." From an "enforcement" point of view
I like that, but realize it's really not what Interfaces as we have them now
are.
best, Bill
.
- Follow-Ups:
- Re: Static Classes ... in response to B. Voigt's comments
- From: Ben Voigt [C++ MVP]
- Re: Static Classes ... in response to B. Voigt's comments
- From: Peter Duniho
- Re: Static Classes ... in response to B. Voigt's comments
- References:
- Static Classes
- From: Prefers Golfing
- Re: Static Classes
- From: Bob Powell [MVP]
- Re: Static Classes
- From: Bill Woodruff
- Re: Static Classes
- From: Jon Skeet [C# MVP]
- Re: Static Classes
- From: Ben Voigt [C++ MVP]
- Re: Static Classes ... in response to B. Voigt's comments
- From: Bill Woodruff
- Re: Static Classes ... in response to B. Voigt's comments
- From: Peter Duniho
- Static Classes
- Prev by Date: Re: Static Classes ... in response to B. Voigt's comments
- Next by Date: Re: output from a process: StandardOut, or Pipes
- Previous by thread: Re: Static Classes ... in response to B. Voigt's comments
- Next by thread: Re: Static Classes ... in response to B. Voigt's comments
- Index(es):
Relevant Pages
|