The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Why choose monostate over singleton?

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Darrell Norton

Posts: 876
Nickname: dnorton
Registered: Mar, 2004

Darrell Norton is a consultant for CapTech Ventures.
Why choose monostate over singleton? Posted: Jun 24, 2004 11:34 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Darrell Norton.
Original Post: Why choose monostate over singleton?
Feed Title: Darrell Norton's Blog
Feed URL: /error.htm?aspxerrorpath=/blogs/darrell.norton/Rss.aspx
Feed Description: Agile Software Development: Scrum, XP, et al with .NET
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Darrell Norton
Latest Posts From Darrell Norton's Blog

Advertisement

A while back I was wondering what the pragmatic difference was between singleton and monostate. Recently someone named Ken left a comment that described why someone would use monostate over singleton other than personal preference.

To recap, the singleton pattern structurally enforces the fact that you can never have more than one instance of a class at a time, and it is obvious to the developers that they are dealing with a singleton. On the other hand, the monostate pattern enforces the behavior of a singleton without the structure of a singleton, e.g., the singleton behavior is encapsulated from the developers.

So why choose one over the other?

“If you plan on deriving classes from the singleton and you want those classes to be singletons, your better choice is monostate. That's because all classes derived from a monostate are monostates. Classes derived singleton classes are not singletons by default. You would have to add the static method and attribute to each derived class.”


This Blog Hosted On: http://www.DotNetJunkies.com/

Read: Why choose monostate over singleton?

Topic: hidden__viewstate Previous Topic   Next Topic Topic: Another sneak preview of VB 2005 on MSDN...

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use