Builder pattern and singletons
- by Berryl
Does anyone have any links to some code they like that shows a good example of this in c#?
As an example of bad code, here is what a builder I have now looks like. I'm trying to have a way to keep the flexibility of the builder pattern but not rebuild the properties.
Cheers,
Berryl
public abstract class ActivityBuilder
{
public abstract ActivityBuilder Build();
public bool IsBuilt { get; protected set; }
public IEnumerable<Project> Projects {
get {
if(_projects==null) {
Build();
}
return _projects;
}
}
protected IEnumerable<Project> _projects;
// .. other properties
}