$ whoami
Erik Wallin
Full Stack Developer
Consultant / Consultant Manager @ DevCode
@c01ac0ca
This talk is about clean code from a different view
https://www.simplypsychology.org/maslow.jpg
Maslow's hierarchy of needs
Understand code
Deliver business value
Collective ownership
Collaboration and continuous improvement
Learn from each other
Be proud of your work
Affect technology choise
Capital letter starts a sentence
vs
Classes are substantives that starts with a capital letter
One and only one space between sentences
vs
Use one(1) strategy for spacing
val i = 0 / val i=0
No misspelled words
vs
No misspelled variable/function/class names
Invalid parts of texts are removed (strike through)
vs
Remove unused variables and other dead code
No grammatical errors
vs
No warnings
return entityServiceRegistry.getEntityService(type)
.flatMap(entityService -> entityService.getEntity(Long.parseLong(id))
.flatMap(entity -> entityServiceRegistry.getEntityService(sourceType)
.flatMap(sourceEntityService -> {
......
}
Inside a file, the tool is blank lines (0, 1, 2) to visually separate blocks
2 > 1 > 0
Never blank lines inside a function. Text without blank rows is only hard to read if it is too long
Python/C#/Scala/JavaScript support more classes / functions in a file - consider 2 blank lines.
Shared code philosophy / Collective ownership
Exercise: What is important in code for each team member?
Don't even ask for time to do it!
Cyclomatic complexity
Too much mocking is a sign of code smell