Builder pattern and singletons
Posted
by Berryl
on Stack Overflow
See other posts from Stack Overflow
or by Berryl
Published on 2010-04-05T04:13:20Z
Indexed on
2010/04/05
4:23 UTC
Read the original article
Hit count: 405
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
}
© Stack Overflow or respective owner