views:

150

answers:

2

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

}
A: 

Refer to this link for a Builder pattern example: http://sourcemaking.com/design_patterns/builder/c%2523

navr
+1  A: 

This link addresses the pattern I was looking for, as does this one.

Berryl