4 ms·
Typo in that updated Example (1), should have been: int totalBalance = savingsBalance + checkingBalance + brokerageBalance; It's hard to explain such complica
by seadan83 3y ago
Typo in that updated Example (1), should have been:
int totalBalance = savingsBalance + checkingBalance + brokerageBalance;
It's hard to explain such complicated concepts super concisely. What I'm getting is that DRY is often equated to merely making code generic and re-used, while the goal of DRY is not at all about re-use. Generic code is more complicated than non-generic code, thus if we make code generic for the sake of making it used in many places - that is likely going to make things more complex. It's a fundamental misunderstanding that DRY is simply the act of using human pattern matching to make all similar looking code generic and re-used. Instead DRY is more about: "are we sanitizing data before sending it to the front-end? Than that should be done in one place." "Where are we configuring database connections?" etc..
Further DRY should not be the only guiding factor, SRP & coupling should always be considered at the same time as DRY.