Designing one of the application, here one of the scenario is like,
1) pull data from database Or API and 2) post to API
so, It looks like, this suite to Builder design pattern as follow:
I did not see example where builder pattern is used to construct object by reading data from database. Is it suitable pattern while constricting object from database or API retrieved data OrElse, its wrong design ? Example:
public class ResultBuilder
{
private IList<Parts> _parts;
private IList<Dealers> _dealers;
private int resultSetId;
public ResultBuilder(int resultSetId)
{
this.resultSetId = resultSetId;
}
public ResultBuilder PrepareParts()
{
//call to PartsService and pull from database based on resultSetId and prepare List<Parts>.
}
public ResultBuilder PrepareDealer()
{
//call to DealerService and pull from database and prepare List<Dealer>.
}
public IList<Dealers> Build()
{
//Build Dealers and Parts mapping for Dealer.Parts and return;
}
}
client: ResultBuilder.PrepareParts().PrepareDealer().Build();
Aucun commentaire:
Enregistrer un commentaire