lundi 2 mars 2015

Singleton Pattern Still Viable? [on hold]

Question


On MSDN, the singleton is flagged as outdated pattern, is it still a viable pattern, or are there equivalent patterns out there?


Background


Coming from PHP, the singleton pattern used to be my go to pattern to prevent multiple instances of the same object. But now with C# it looks like that there are some alternatives out there, but i don't know witch one is the right thing for me.


Object Definition



using Relink.Data.Enum;
using System;

namespace Relink {

public class Settings {

public Difficulty Difficulty {
get;
set;
}

public Boolean CaptureMouse {
get;
set;
}

internal void loadDefaults() {
this.Difficulty = Difficulty.Normal;
this.CaptureMouse = false;
}

}

}


Remarks


The Settings object is instantiated once upon application-start, but since i'm not the only one working on that application, i want to prevent that there are multiple instance floating around.


Aucun commentaire:

Enregistrer un commentaire