
#2 Swift code refactor in action - price $$$
Swift code refactor in action šØš»āš» Today, letās talk about refactoring for clarity, maintainability, and scalability! This time, the scenario is calculating the final price depending on the price and membership status. This initial code has a few code smells: 1ļøā£ nested ifs - impacts general readability, making the code hard to understand, 2ļøā£ duplicated conditions - āprice > 100ā which violates the Donāt Repeat Yourself principle, 3ļøā£ lack of scalability - not possible to easily add a new discount, itād require to rework everything. Checkout the gif or the post on my website to see how I solve these code smells and make the code cool, clean and scalable! ...