reading versus writing is well over 10 to 1. We are constantly reading old code as part of the effort to write new code. ... [Therefore,] making it easy to read makes it easier to write.” ― Robert C. Martin, Clean Code: A Handbook of Agile Software Craftsmanship
way to eat an elephant: a bite at a time." understandlegacycode.com “Legacy Code is code without tests” Michael Feathers: Working Effectively with Legacy Code
null && !password.isBlank(); if (isNotBlank) { boolean hasSpecialChar = password.chars().anyMatch(Character::isLetterOrDigit); if (hasSpecialChar) { boolean longEnough = password.length() >= 10; if (longEnough) { return true; } else { throw new IllegalArgumentException("Must be at least 10 characters"); } } else { throw new IllegalArgumentException("Must contain at least one special character"); } } else { throw new IllegalArgumentException("Password must not be blank"); } } public void checkPasswordStrength(String password) { if (password == null || password.isBlank()) throw new IllegalArgumentException("Password must not be blank"); if (password.chars().noneMatch(Character::isLetterOrDigit)) throw new IllegalArgumentException("Must contain at least one special character"); if (password.length() < 10) throw new IllegalArgumentException("Must be at least 10 characters"); } vs
void checkNotBlank(String password) { if (password == null || password.isBlank()) throw new IllegalArgumentException("Password must not be blank"); } private void checkHasSpecialCharacter(String password) { if (password.chars().noneMatch(Character::isLetterOrDigit)) throw new IllegalArgumentException("Must contain at least one special character"); } private void checkHasMinimumLength(String password) { if (password.length() < 10) throw new IllegalArgumentException("Must be at least 10 characters"); } public void checkPasswordStrength(String password) { if (password == null || password.isBlank()) throw new IllegalArgumentException("Password must not be blank"); if (password.chars().noneMatch(Character::isLetterOrDigit)) { throw new IllegalArgumentException("Must contain at least one special character"); } if (password.length() < 10) { throw new IllegalArgumentException("Must be at least 10 characters"); } } vs
{ this.password = password; checkNotBlank(); checkHasSpecialCharacter(); checkHasMinimumLength(); } private void checkNotBlank() { if (password == null || password.isBlank()) throw new IllegalArgumentException("Password must not be blank"); } private void checkHasSpecialCharacter() { if (password.chars().noneMatch(Character::isLetterOrDigit)) throw new IllegalArgumentException("Must contain at least one special character"); } private void checkHasMinimumLength() { if (password.length() < 10) throw new IllegalArgumentException("Must be at least 10 characters"); } ... }
business stakeholders • Hard to explain the need for refactoring. [don't] • Easy to explain the need for quality. [do] • You will fall when you run too fast. You may make the finish, but you won't be able to run the next race.
How Do We C SOFTWARE DEVELOPMENT SOFTWARE DEPLOYMENT SERVICE OPERAT Lead Time Change Fail Availability Deployment Frequency Time to Restore FOUR KEY METRICS The first four metrics that capture the effectiveness of the development and delivery process can be summarized in terms of throughput and stability. We measure the throughput of the so ware delivery process using lead time of code changes from check-in to release along with deployment fr Stability is measured using time to r the time it takes from detecting a us impacting incident to having it rem and change fail rate, a measure of t of the release process. PERFORMANCE METRICS # of Tests
making it work • Spend time to make it communicate • Your understanding of a codebase will grow • Any time you see or touch code, make it fit your latest insights