Clean Code Words Flashcards
DRY
Don’t repeat youself.
If you need to copy code create a function for it.
KISS
Keep it simple stupid.
Create functions/classes as simple as possible
Beware of Premature Optimization
Optimize only when its necessary and required.
Rules of Optimization:
Rule 1: Don’t do it.
Rule 2 (for experts only): Don’t do it yet.
FCoI
Favour Composition over Inheritance
„Because inheritance exposes a subclass to details of its parent’s implementation, it’s often said that ‚inheritance breaks encapsulation„. (Gang of Four 1995:19)
IOSP
Integration Operation Segregation Principle
IOSP uses a clear separation for function logic.
- A method (called Operation) contains only logic Transformationen, Controllstructures, I/O- or API-calls.
- A method (called Integration) contains no logic only method calls of the same code base
Boy Scout Rule
Every time you work on some code it may get a little bit better. Without bureaucratic planning.
Clean code developers leave code in a better state than they found it. So after work accomplished code shall apply more to CCD values than before.
Root Cause Analysis
knowing the root cause, clean-up tends to be less effert than curing symptoms
Root Cause Analysis is also known as “Five Why’s”.
This term origins from the Toyota Production System (TPS) stating the basic idea to ask “Why?” five times.
Version Control
Being afraid of damaging a running system paralyzes software development. Using version control that fear is obsolete and development can progress quickly and bravely.
Simple Refactoring Patterns
Improving code is easier if you know typical improvement patterns. Their usage scenarios sensitize for weaknesses in self-written code. As accepted patterns they encourage to be applied.
Daily Reflection
There is no improvement, no progress, no learning without Reflection. But only if reflection is on the schedule, it will happen under daily business pressure.
SLA
Single Level of Abstraction
Within one method you should use only one level of abstraction. Otherwise the reader will find it hard to differentiate essentials from details. So if you need to fiddle with bits, don’t combine it with method calls.
Lines of code may have different levels of abstraction. Assigning a value to a variable is on a lower level than let’s say a method call.
SRP
Single Responsibility Principle
A class having exactly one task is easier to understand than a convenience store
SoC
Separation of Concerns
If a code unit does not have a clear purpose, it will be difficult to understand, difficult to use, difficult to enhance and difficult to correct.
You should not combine multiple concerns in one class. What is a concern?
Concerns a “completely different” purposes.
Concern are considered to be orthogonal to each other and especially orthogonal to the main functionality of a functional unit. Samples for typical concerns are: Tracing, logging, transaction handling, caching. If you follow SoC principle, you will extract these concerns into specialized functional units.
Source Code Conventions
Code is more frequently read than written. Accordingly conventions are important to support reading and conceive code quickly.
Issue Tracking
Only written issues are not forgotten and can be efficiently followed-up or delegated.
Automatized Integration Tests
Integration tests ensure the code does what it shall do
Read, Read, Read
Reading educates!