Factory Pattern but with object Parameters

前端 未结 7 1880
春和景丽
春和景丽 2021-02-02 11:05

Take the following classic factory pattern:

public interface IPizza
{
    decimal Price { get; }
}

public class HamAndMushroomPizza : IPizza
{
    decimal IP         


        
7条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-02 11:54

    You could pass a new parameter, such as a Map. And query the properties on each concrete constructor. Then all the methods would have the same signature. However, with this solution, the caller of the constructor has to know the specific properties of the concret constructor...(Coupling)

提交回复
热议问题