Differentiate ingredient product

2

I am trying to make a system for selling acai berry. In an açaí can add many ingredients like paçoca, milk powder, fruits and etc ... Açaí can also be sold in pots of 250ml, 500ml and 750ml. Depending on which pot is sold, an N amount will be removed from the stock. The same applies to the added ingredients. It is worth remembering that the establishment also sells bottles of water, juices, soft drinks, which do not cease to be products!

Anyway, I'm trying to make the template, and until then I find myself like this:

I'vesetanIngredientandaProducttobeatypeofItem,sincetheyhavestock,haveapriceingredientwilladdtothefinalpriceoftheproduct),sotheyinheritfromtheabstractItemclass.TheIngredientclasshasalistofcategoriesthatcanbeadded,forexample:MilkpowdercanbeaddedintheAcaicategory,butneverintheRefrigerantcategory.

Iwanttoknowifthemodelisgood,Ithoughtaboutusingthedecoratorpattern,butIdonotknowifIwillhaveproblemsinsertingintothedatabase.IwilluseC#andFluentNhibernatewithMySQL.Anyway,howtosolvethe250ml/750mlpotproblem?Andthefactthatnotallingredientsarecompatiblewithallproducts,didItakeagoodapproachtotheproblem?

Iacceptsuggestionsonanypartofthetemplatetotrytosolvetheproblem,aslongastherearenoproblemstowritetothedatabase(whichisalsosubjecttochange).

EDITFollowingadvice,Ichangedthediagramandthisoneissonow: Solved the problem of a product may come to spend X inputs. But I am now in the following situation. If my client buys a bottle of water from a supplier, he sells the whole water bottle without spending any input, the bottle is the stock itself, how to solve it? I thought about creating a stock class, but how could I connect to the Stock Input and Product at the same time?

    
asked by anonymous 27.10.2014 / 18:10

1 answer

1

I suggest starting from a well-developed problem, and designing the model to solve this problem, implement the software, and then move on to the next problem, which may imply a refactoring of the model and software already developed. This approach can be called Emerging Design , and is very fashionable: -)

For example:

  

Problem: to download stock of inputs from the manufacture of a   product.

Modeling to solve this problem:

  • Input (ex: Milk powder, paçoca, banana)

  • Product (ex: Acai, Vitamin)

  • Product composition (inputs used to manufacture a product)

  • Down Payment (from the manufacturing of a product)

When a product is manufactured, several records are added to the entity "Low of Input" , and the stock of inputs is updated (fractions or units of the ).

Tip: Leave inheritance to the end. Do not start modeling already thinking about inheritance. Start by imagining that you can not rely on this feature. The reason is simple: inheritance adds complexity and we always try to keep the system as simple as possible.

    
27.10.2014 / 19:14