16. • “In fact, zero -- as a number or a concept -- is a shockingly new idea in
western civilization. For nearly everyone in Europe, such a thing was
unthinkable until the 14th century at the earliest. That's nearly 1,000
years after zero's invention.”
20. public interface UserRepository {
public void add(User user);
public void addAll( Collection<User> users);
public void remove(User user);
public void removeAll(Collection<User> users);
...
}
21.
22. public interface WorkManager {
void doAtomic(CheckedConsumer<RepositoryContext> consumer) throws TransactionException;
<T> T unit(CheckedFunction<RepositoryContext, T> mapper) throws TransactionException;
}
29. Yin : Yang
is a concept of dualism,
describing how seemingly opposite or contrary forces may actually be
complementary, interconnected, and interdependent in the natural
world.
39. Org : Architecture
• Conway’s law
• Self organizing teams
• Loosely coupled organizations
40. public static int ? (int i) {
i = i - ((i >>> 1) & 0x55555555);
i = (i & 0x33333333) + ((i >>> 2) & 0x33333333);
i = (i + (i >>> 4)) & 0x0f0f0f0f;
i = i + (i >>> 8);
i = i + (i >>> 16);
return i & 0x3f;
}
42. Compose method pattern
void someMethod(){
//do some stuff
line 1
line 2
line 3
//calculate some other stuff
line 4
line 5
line 6
//do final stuff
line 7
line 8
line 9
}
void someMethod(){
doSomeStuff();
calculateSomeOtherStuff();
doFinalStuff();
}
void doSomeStuff(){
line 1
line 2
line 3
}
void calculateSomeOtherStuff(){
line 4
line 5
line 6
}
void doFinalStuff(){
line 7
line 8
line 9
}
43. Secondary benefits
• part-methods become better tested
• part-methods and whole-methods are scrutinized more
• part-methods become use-able in multi-contexts
• part-methods are closed before the whole
96. • Refactoring (continuous, opportunistic, preparatory)
• always leave the code behind in a better state than you found it
• danger of going down a rabbit hole here
97. Transformations
• ({} → nil) no code at all → code that employs nil
• (nil → constant)
• (constant → constant+) a simple constant to a more complex constant
• (constant → scalar) replacing a constant with a variable or an argument
• (statement → statements) adding more unconditional statements.
• (unconditional → if) splitting the execution path
• (scalar → array)
• (array → container)
• (statement → tail-recursion)
• (if → while)
• (statement → non-tail-recursion)
• (expression → function) replacing an expression with a function or algorithm
• (variable → assignment) replacing the value of a variable.
• (case) adding a case (or else) to an existing switch or if
98. public static int sumIterative(List<Integer> list) {
int sum = 0;
for(int element:list)
sum = sum + element;
return sum;
}
public static int sumRecursive(List<Integer> list) {
if(list.size() == 0)
return 0;
return list.get(0) + sumRecursive(list.subList(1, list.size()));
}
117. Top down : bottom up
Working top-down, we cannot produce an acceptable decomposition of
a given problem in terms of available abstractions, but working
bottom-up, we cannot produce an acceptable composition of available
abstractions to solve a given problem.