Proverbs on software development(v1)
- A function should do one thing and do it well
- If an egg is broken by an outside force, life ends. If an egg is broken by an inside force, life begins.
- There are 2 hard things in CS: “cache invalidation and naming things”.
- Testability is a design issue and needs to be addressed with the design of the rest of the system
- a testable system can evolve easily
refactoring
it comes from here
- Improving the design of code without changing its external behavior
- Refactoring is not...If the changes affect external behavior, it’s rewriting, not refactoring.
- continuous small steps: Refactoring should be done as a part of our every day work flow. Don’t wait for massive “big bang” refactorings.
- Investment When to refactor? It’s an investment:- Makes change easier.- Helps find bugs. But comes with time and effort cost.
- makes code clear to other people, Not machines
- Martin Fowler“Any fool can write code that a computer can understand. Good programmers write code that humans can understand.”
From the book “Refactoring”
- It’s much more important to write code that will be easy to understand by other people than just understood by a browser.
- clarity vs performance
- clarity enables performance: Some of you have heard that “Premature optimization is the root of all evil”. Its easier to optimize clean code than to clean up "optimized" code.
- CODE SMELLS
- Code is like cheese.Some people find smelly what other find deliciously wonderful.
- duplication: It makes change harder.The rule of 3: the third time you copy something, it’s time to refactor.