1 slide on why, 3 slides on what, examples are a good way to communicate about clean code. Some examples using code.I use the book Clean code by Robert Martin.
1,2: Communication : So to minimize the cost of maintenance, your code should be clear to those people (or yourself) reading it a later date. It should be nice to read, it should clearly communicate its design, and it should not be overly complex.3: After we all read GoF’sDesign Patterns, a lot of books were talking about design patterns and then about architecture patterns. And after that our attention shifted towards process (XP, Agile). It is good to remember that the “mundane” task of writing code is something we still can and must improve.
From the book Clean code by Robert Martin.
Does this help ?
Clean code – A Handbook of Agile Software Craftsmanship – Robert MartinDon’t use comments to describe code. . Only use comments when the code can not tell it.No magic numbers -> use constantsStyle -> indenting
SOLID: SRP, OCP, LSP, DIP, ISP
Does two thingsTwo differentreasons to change
=> Split it up in two classes
Only about 10 lines. But it tests for testpage and then also includes pages
isTestPage() should be defined just below. And below that should be includeSetup….
For loop can have a inti as variable, when the scope is smallEncodings: it should read well (don’t abbriviate). Also don’t use hungarian notation etc.
Two/three: ordering of arguments is a problem. => mix upassertEquals(expected, actual);Flag: the call is confusing ! => split it up
Duplication is a problem for maintenance. You have to remember to change it in multiple locationsBeck (XP)Also Ron Jeffries says it is the second most important rule, just after getting the tests to passSwitch/case can be solved with polymorphismsDuplication is one of the big code smells that prgrammers have to solve
Easy: 3 lines of identical code=> Create new method
Higher level of abstraction: new method name describing what it doesTotal is 1 line less code
Every time you have an opportunity to change code, make sure it is a little cleaner.