5. You are reading
this book for two reasons.
First, you are a programmer.
Second, you want to be
a better programmer.
Good. We need better programmers.
9. Agile Manifesto
Individuals and interactions
over processes and tools
Working software
over comprehensive documentation
Customer collaboration
over contract negotiation
Responding to change
over following a plan
10.
11. public List<int[]> getThem() {
List<int[]> list1 = new ArrayList<int[]>();
for (int[] x : theList)
if (x[0] == 4)
list1.add(x);
return list1;
}
12. public List<int[]> getFlaggedCells() {
List<int[]> flaggedCells = new ArrayList<int[]>();
for (int[] cell : gameBoard)
if (cell[STATUS_VALUE] == FLAGGED)
flaggedCells.add(cell);
return flaggedCells;
}
13. public List<Cell> getFlaggedCells() {
List<Cell> flaggedCells = new ArrayList<Cell>();
for (Cell cell : gameBoard)
if (cell.isFlagged())
flaggedCells.add(cell);
return flaggedCells;
}
20. Open Closed Principle
Finish what you start
the routine or object
that allocates a resource
should be responsible
for deallocating it
21. Law of Demeter
More formally, the Law of Demeter
for functions requires that
a method M of an object O
may only invoke the methods of
the following kinds of objects:
1. O itself
2. M's parameters
3. any objects created/instantiated within M
4. O's direct component objects
5. a variable, accessible by O, in the scope of M
28. This work by
Fredrik Wendt
is licensed under a
Creative Commons
Attribution-NonCommercial-ShareAlike
3.0 Unported License
http://creativecommons.org/licenses/by-nc-sa/3.0/
Editor's Notes
Detta gjorde vi sist.
Alla borde känna igen cirkeln
helst 1 minut från red till green
fokus på refactor-steget [för det låter oss...]
Primary user of our code is coders - it&apos;s you!
x % of the time we&apos;re reading code, not writing.
[men boken handlar om ...]
Qode quality och clean code,
[vad menar boken med detta]
Vi bryr oss om olika saker
Fokus idag = gemensamma saker
[Konkret exempel först]
when one wants to walk a dog, it would be folly to command the dog’s legs to walk directly; instead one commands the dog and lets it take care of its legs itself.
Strategi kring exceptions
checked vs unchecked
log vs rethrow
hur mycket kod är ok inom try - catch? (en rad, ett uttryck, jfr med Jms-koden:openConnection()openSession()openProducer()openConsumer()connection.start() ...