Control of negative residues

Controlling negative balances is when a buyer stands in front of you, holds in his hands something that he is going to buy, and the system tells you: but this is not available, I will not formalize the sale! The funny thing is that at first glance everything seems logical and rational. Man tends to be wrong. His hand may tremble and instead of 10 pieces. he will enter 100 and will not notice. And at this moment, a kind and vigilant system will tell him the way to the truth. And this is how it happens in those rare (well, very!) Cases when they introduce 100 instead of 10, and in the warehouse there are exactly those 10. But warehouses, they are warehouses to store a lot, a lot. And if at the time of the user error there is not 10, but 100, 1000 or 10,000 in the warehouse, then the system will cease to be vigilant and fall asleep for a day, a week, a month ... It would be better,if she fell asleep forever (why - you will understand a little later), but, unfortunately, sooner or later the system wakes up. And you find yourself in the situation that I described at the very beginning. Here they are - these 10 pieces. in the hands of the buyer. And no one's hands tremble. 10 pieces. the buyer has the same 10 pcs. the user tries to enter the system. But it was not there! The system shouts at you: stop! Stop! Stop! negative balance! And what should the user do now? Take a deep breath and start checking all the documents with this product for a day, a week, a month ... How lucky. If you are very lucky, a fairy from a famous anecdote will fly in and everything will be "for real." In our case, "for real" is when the reason for the negative balance is not an error when entering a document, but the omission of an incoming document.Finding a black cat in a dark room is especially difficult when she is not there. Now the user will view documents not in a week or a month, but in general. For all the time. Will not find errors. Take another deep breath. Will carry out an inventory of the warehouse. Will register the receipt of the goods ... All this time, the sales of this product will stand (ha! Ha!) Here it is - the programmer's revenge!





The most surprising thing about this story is how widespread this "wonderful" algorithm is now. The user’s superstitious horror of negative numbers can still be understood somehow. But how can you explain the dislike of negative numbers on the part of developers? On the part of those who, after all, are not good at mathematics? A negative number is the same number as a positive one. And what, in principle, can be bad negative balance? Whom can he harm? Here the positive can hurt. And very much. Don't believe me? Then imagine that you have a "good", positive balance in your system, 100 tons of apples. And in warehouse 0. And a client who has already paid for this "good" balance comes up to you. And now he wants his ten heavy trucks to be loaded immediately. But the "bad"the remainder would never lead you to this situation, would it? As you wish, but personally, I would first control the positive balances, and only then, at my leisure, negative ones.





, " ". , , . , . . , . :





, , . . 10 . 5 . 10 . ? , , . . - . ? , 0 ., 5 . 5 . . , , . . .. 5 . . 10 , , 5 . , . . , - . . . !





, . , , . . . , , .





. - , . , , . . , , . - . , . , , - : , . ( , ). .





, , . . , . - . ( !) . ? .





, , , ("" ) . , - . . , , , . , . . , . , . , . . , . . . . , . . ! . , ( ) . , . , , . - . . , . , , .





- , . - ( , ), . , .





. ? . . . . . ( ) . . . ? , -? . , , . , , . , , . , . . . , . , . , , - "". , - . . , , .








All Articles