State pattern and an order state machine
An e-commerce order moves through several states: new, paid, shipped, delivered, cancelled. Each action, such as paying, shipping or cancelling, is valid only in certain states, and the behavior diffe...
Programming articles from Sudo engineers: Java design patterns, Python, AI and data, and web development, with runnable code examples.
An e-commerce order moves through several states: new, paid, shipped, delivered, cancelled. Each action, such as paying, shipping or cancelling, is valid only in certain states, and the behavior diffe...
In the previous article, TF-IDF treated "ô tô" and "xe hơi" (two Vietnamese words for "car") as two completely separate columns: nothing says they mean almost the same thing. The model only knows the...
A news site receives several hundred stories a day and must file each one under the right section. An online store has to sort customer feedback into "delivery", "payment" or "warranty". Both are text...
An order entering the system has to pass several checks: is the customer logged in, is the item in stock, does the payment exceed the limit. If you write all of that in one long method full of nested...
A store wants to know how many bottles, cans and cartons are left on a shelf, and where they sit. The image classifier from the previous article only answers "which class is this image?", but inventor...
The shopping cart of an online store needs three things that direct method calls cannot give it: an "Undo" button after a customer accidentally deletes an item, a "Redo" button when they change their...
You have 244 training images, two classes (ants and bees), and you want an image classifier. Training a CNN from scratch gives 71.9% on the validation set (153 images: 70 ants, 83 bees, so always gues...
Getting a neural network to run once does not mean you know how to do deep learning training reliably. Change the learning rate from 0.001 to 0.1, with the same model and the same data, and accuracy c...
Three reports in a sales system: a CSV export, an HTML export, and a CSV export for orders of 1,000,000 VND or more. All three open a connection, filter, print a header, loop over rows, print a footer...
Frameworks like PyTorch let you train neural networks in a few lines, but when the loss stops falling or the gradients vanish, you can't tell where to start unless you understand what happens inside....
In earlier articles we wrote gradient descent by hand with NumPy: derivatives worked out on paper, updates applied manually. That approach teaches the fundamentals, but it breaks down once a model has...
When an order moves to the "paid" state, the system has to decrement stock, email the invoice, write an audit log entry and notify the accounting system. If OrderService.pay() calls all four directly,...
All articles are displayed