Differentiate product from ingredient

Asked

Viewed 228 times

2

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

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

inserir a descrição da imagem aqui

I defined that a Ingredient and a Product are a type of Item, because they have stock, has a price (which in case of the ingredient will add to the final price of the product), therefore they inherit from the abstract class Item. The class Ingredient has a list of categories that can be added, for example: Milk powder can be added in the category Acai, but never in the category Soda pop.

I want to know if the model is good, I thought about the possibility of using the default Decorator, but I don’t know if I’ll have problems entering the database. I will use C# and Fluent Nhibernate with Mysql. Anyway, how to solve the 250ml/750ml Pot problem? And the fact that not all ingredients are compatible with all products, I made a good approach to the problem?

I accept suggestions on any part of the model to try to solve problem, as long as there are no scams to write to the database (which is also subject to changes).

EDIT Following advice, I changed the diagram and this is now: inserir a descrição da imagem aqui Solved the problem of a product can come to spend X inputs. But now I find myself in the following situation. If my client buys a bottle of water from a supplier, he sells the whole bottle of water without spending any inputs, the bottle is the stock itself, how to solve? I thought about creating a stock class, but how could I connect to the stock Input and Product at the same time?

  • In what other category Leite em pó can be added in addition to Açaí? Some ingredient can be added in the category Refrigerante?

  • 1

    It seems to me that you are trying to solve with a single model an immense amount of problems (stock of inputs, control of inputs used in the manufacture of the product, stock of products, ...) and these problems seem to be not yet well formulated - for now there is only a general notion of all problems. My suggestion: choose the most important problem, define it well, design a model that suits you, implement, validate. Choose the next problem, define it well, refactor the model, implement, validate. Repeat the cycle.

  • I think it is important to separate the concept of stock from the concept of the final product sold, because in practice, they are different things. The banana you put in the açaí is not an item, nor the açaí, because you buy in a "format" and sell fractionated. Just like an item in a building store stock is cement, and you can sell 1kg of cement separately (fractionated). In stock you have 60kg cement bags. Better not mix concepts forcibly. The stock has kilos of banana, açaí has units. The stock has quantities of açaí, which are fractionated and turn products.

  • @Caffé I believe not, I wanted to leave free for the user to define this, because if he wants to create the vitamin product and say that there are things that can be increased, he can do this.

  • @Bacco Because of lack of knowledge in planning I do not understand the subject well, however, does this not generate duplicate content? In stock I have Açai 800ml, and in Item I have Açai, too? How does the input relate to the product? Is the stock of the input or the product? And when the product is whole?

  • 2

    @Lizard Vc has products that "relate" to the stock. You can have a product table with a reference like this: The product Açai 750ml "discounts" 0.75 L from açaí stock, if the stock entry is in liters, for example. The optional Banana discounts 50g of the Kg of banana, and so on.

  • @Bacco then I’ll have to create a spending table? My customer when registering a new product will inform that the product X spends Y of so many ingredients?

  • @Lizard is what I would normally do in this case, but there are a lot more details that a good stock has to have to close round (conciliation of losses, etc). It is up to you to evaluate what is best in the real case. There are many possibilities for me to comment here. There is no universal rule, each case is a case.

  • I will follow the advice of both of you and remodel. I will then edit with the changes to (if you want) evaluate

  • 1

    I added a reply with a suggested template. Feel free to ask I can add more details.

Show 5 more comments

1 answer

1

I suggest starting from a well elaborated problem, and designing the model to solve this one problem, implement the software, and from there proceed to the next problem, which may imply a refactoring of the model and software already developed until then. This approach can be called "Design Emergente", and is very fashionable :-)

For example:

Problem: Download stock of inputs from manufacturing a product.

Modeling to solve this problem:

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

  • Product (e.g.: Acai, Vitamin)

  • Product composition (inputs used in the manufacture of a product)

  • Low Input (from the manufacture of a product)

When a product is manufactured, multiple records are added to the entity "Baixa de Insumo", and the stock of inputs is updated (fractions or units of the entities are deducted "Input").

Tip: Leave legacy at the end. Don’t start a template with inheritance in mind. Start by imagining that you can’t count on this feature. The reason is simple: inheritance adds complexity and we always try to keep the system as simple as possible.

  • When the product is for example a water bottle it is product, has no composition, but has stock. How to solve this situation?

  • I updated the question

  • @Lizard You want to keep stock information only of the resold products or also of the own manufacture (ex: 10 paçoca açaís in the freezer)?

  • only ready (water bottle) and inputs

  • @Lizard How about renaming Input for Product and Product for Manufactured Product?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.