Member-only story

How I ruined the implementation of the shopping cart, several times.

And how you can avoid it.

David Rodenas PhD
7 min readApr 2, 2022
Photo by Alexas_Fotos on Unsplash

I have been a programmer for a long time. I developed and delivered my first commercial shopping cart more than 30 years ago. And it was not the best code. Even after taking a degree in CS, I was still failing to comprehend how to do a proper implementation.

Here I show how I have ruined the implementation several times; but not only the shopping cart, it can be applied to any other code. I help you to understand how it was ruined, and how to fix it. And more important, how to know which implementation fits to each case.

Two core principles in software design

The first thing that I have to explain to you is that there are two core principles that affect every design: derived values and dependency arrows.

Derived Values: are values that change when other values change. The classic example is the age: it changes each year, it is a derived value from birthdate and current date. Another example is the price of the shopping cart: it is derived from product prices and quantity in the cart.

There are two strategies for implementing derived values: computed and materialized. Computed is having a function that computes its value each time that…

--

--

David Rodenas PhD
David Rodenas PhD

Written by David Rodenas PhD

Passionate software engineer & storyteller. Sharing knowledge to advance our skills. Join me on a journey of discovery in the world of software engineering.

No responses yet