We favor separation of functional code from stateful code. For example we separate the Till concept (which is functional) and the Cart concept (which

joelparkerhenderson / demo-shopping-cart-exercise-with-ruby

submited by
Style Pass
2021-06-09 23:30:05

We favor separation of functional code from stateful code. For example we separate the Till concept (which is functional) and the Cart concept (which is stateful).

We favor separation of domain concerns. For example we separate the Till concept (which focuses on the concern of tallying a total cost) and the Offer concept (which focuses on the concern of special-case discounts).

We favor test driven development (TDD) which writes a test and runs the test to prove it fails, then implements the logic and runs the test to prove it succeeds.

We favor Ruby Minitest test style with assert(), rather than Minitest spec style with expect(), because the test style tends to be faster to write, clearer to document, and more effective to refactor as needed.

Money units tend to be better to implement as the smallest-necessary unit rather than as a decimal floating point number. I.e. we implement using cents and integer math, not pound and floating point math.

The method Shop.item_cost is a class method, rather than an instance method. The class method is more-akin to a functional approach, and less-akin to an object oriented programming (OOP).

Leave a Comment
Related Posts