Singleton pattern

Category:
Design patterns
Description: The key point is the private constructor which makes sure only one instance is created. For more information, please go to http://en.wikipedia.org/wiki/Singleton_pattern
Code:
type A private () =
static let instance = A()
static member Instance = instance
member this.Action() = printfn "action"

let DesignPatter1() =
let a = A.Instance;
a.Action()

Execution Result:
action

Last edited Sep 14, 2011 at 3:27 AM by ttliu2000, version 2

Comments

No comments yet.