For example, now I want to make a package function for a certain mall (the function has been implemented by itself
The key is to answer the questions marked in red below, thank you~O(∩_∩)O~
The initial function of the mall is just to buy a certain product. The package functions added later have been changed to the original code, and the changes are very big. How should I make judgments in key places in case I need to add additional features later
? How to weaken the coupling of the code and add functions later to reduce modifications to the original code?
For example, now I want to make a package function for a certain mall (the function has been implemented by itself
The key is to answer the questions marked in red below, thank you~O(∩_∩)O~
The initial function of the mall is just to buy a certain product. The package functions added later have been changed to the original code, and the changes are very big. How should I make judgments in key places in case I need to add additional features later
? How to weaken the coupling of the code and add functions later to reduce modifications to the original code?
You may need three tables using mysql for this problem:
Product List
Package list, package description, price, validity period, etc.
The package and product association table basically has two fields, package ID and product ID. Many-to-many relationship, because a package must contain multiple products, and a certain product will also belong to different packages
In specific implementation, two modules can be developed independently for packages and products, which are the functions of adding, deleting, modifying, checking and purchasing of products, and the functions of adding, deleting, modifying, checking and purchasing of packages. The only coupling point between packages and products is the association table. That is, when deleting a product, you need to pay attention to whether it affects the corresponding package. Other functions are basically not coupled
At the same time, your order table can have a type field to indicate whether it is a package order or a single product order