Welcome to MSDN Blogs Sign in | Join | Help

D Melodic Minor Accidental

A conglomeration of random thoughts on C#, .NET, OOP, and working at Microsoft

Syndication

Other Sites

Coming up: Design Patterns

Quick detour (not so much of a detour). 

Cyrus has challenged me to 48 hours in order to expound on how he could've written is IOptional<T> better.  Actually, I started to explain some of my suggestions, but now he's imposed this limit, since he's too antsy for me to really finish writing out my entire rationale. 

So instead of writing real code, we're going to talk more about design and theory for a while... but I have a couple of caveats.

(1) I'm going to assume that you're already familiar with programming in .NET, and my samples will mostly be in C# (though they certainly can be ported to other .NET flavors).
(2) I'm also going to assume that you're comfortable with the semantics for single class-inheritance, as well as virtual methods.  Most of the material won't be directed towards explaining the semantics of the .NET language features, but more along the line of the question, “How do I use this the right way?”.
(3) Virtual methods are prolific throughout abstracted/generalized object oriented programs.  These are slower than “non-virtualmethods, but they also buy a lot of abstraction and scalability in design.  Most people will also agree that the “performance hit is marginal, and the payoff is quite valuable in development time, code complexity, and sustainability.
(4) Most of the examples I'll be writing will not consider thread-safety, which is usually its own can of worms.  The main reason is that for most of the upcoming examples, you can workaround thread-safety by giving each thread separate copies (unless they're supposed to share), or you can wrap synchronization logic using decorators.

With that in mind, let's begin with the singleton pattern.

Singleton Pattern: http://blogs.msdn.com/theoy/archive/2004/05/20/136528.aspx

Published Thursday, May 20, 2004 10:07 PM by TheoY

Filed under:

Comments

No Comments

New Comments to this post are disabled
Page view tracker