What architecture can I use to handle a shopping cart where each product requries different attributes to be saved

后端 未结 4 2048
星月不相逢
星月不相逢 2021-02-06 15:25

I am building an application that is very similar to a shopping cart. The user selects a product from a list, and then based on that product, a few properties need to be set an

4条回答
  •  野的像风
    2021-02-06 16:03

    I would avoid making a class for each product. Each of your products are instances of the same Product class.

    With such variable properties, a dictionary approach (basically a map of key-value pairs, type specific or not, is a great way to retain flexibility in the design. You aren't talking about amazon.com sized product inventory, so I think it is a good enough design for the perf you need.

提交回复
热议问题