Views: 7.2K
Replies: 1
Archived
|
Builder Pattern what about parametersHello, in the examples, both here and elswewhere on the internet I see always something like this
public void Construct(Builder builder) { builder.BuildPartA(); builder.BuildPartB(); } Peter G., Sep 30, 2012
|
|
Reply 1Quickly put in here - you could optimize initializations as required (like Singleton etc.,)
Create and Entity Class that encapsulates all the parameters you may need for PartA,B as Properties public class PartsDTO { string _Property1=string.empty; //for simplicity considered a string property public string Property1 { get{return _Property1;} set {_Property1=value;} } } public class Builder { public _PartsDTO=null; public PartsDTO PartsDTO { get{return _PartsDTO;} set{_PartsDTO=value;} } } and within the construct method public void Construct(Builder builder) { builder.BuildPartA(builder.PartsDTO.Property1); builder.BuildPartB(); } thanks, Tarriq Tarriq Ferrose Khan, Oct 01, 2012
|