Answer the question
In order to leave comments, you need to log in
How to understand what things in the Naldo program should be universalized?
What I mean?
For clarity:
let's say we need to get the price of an apartment
It seems that we just store the price and display it
BUT
- what if we need to display it per square meter?
-what if it will be necessary to display in different currencies? (then it is necessary to redo the database for different currencies)
-what if there are possible discounts and it will be necessary to display the full and incomplete price
This is just an example, the question is not about him, but about the situation in general
How understand which parts of the code should be made universal and which ones should be hardcoded?
Despite the fact that the client does not know, let's say he will have other currencies, etc.
Answer the question
In order to leave comments, you need to log in
1. The total value (the value formed by the formula from the final / single ones) is maximally divided into single components of the variable / dependent parameters and for all parameters we create columns in the database (what makes up the cost and how much one part costs) and check the correctness and completeness of its content at the customer.
2. If there can be several parameters, we create a separate table with ID-shniks for several parameters and enter their values there (for example, exchange rates, quality gradations of something, different colors, etc.).
I gave this just an example, the question is not about him, but about the situation in generalIf this is not a social network, where traffic is calculated in petabytes, and the load on the database is thousands of requests per second, then the most rational solution in such matters, in my opinion, was found long ago and is called OOP , incl. for data processing, in many systems (for example, frameworks) there is such an entity as an object (or "model" if you like), in which you can easily add a new property that is calculated dynamically. This works great in most cases.
. How to understand which parts of the code should be made universal and which should be hard to prescribe?
How to understand which parts of the code should be made universal and which should be hardcoded?
If you are just starting to make a project and there is some degree of uncertainty, do not chase universality. It is better to “hard-code” the rules and even duplicate the code in some places than prematurely make a universal solution that will turn out to be inappropriate in the future. When the project lives for some time and the requirements more or less settle down, you will understand which parts of the project can be made universal.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question