1. The document discusses principles of emergent design including contextual force, patterns, commonality variability analysis, and programming by intention.
2. Commonality variability analysis involves identifying what is common and what varies across different contexts for a given problem.
3. Programming by intention focuses on conceptualizing what you want to do at a high level before implementing technical details.
37. CVA Exercise (2)
There are two types of shape (Circle, Square)
There are two types of writer (Pen, Pencil)
Each shape can print itself on different writers
38. CVA Exercise (2)
Pen
write() {
//inkImpl
}
Pencil
write() {
//leadImpl
}
Writer
write()
There are two types of
shape (Circle, Square)
There are two types of
writer (Pen, Pencil)
Each shape can print
itself on different writers
39. CVA Exercise (2)
Pen
write() {
//inkImpl
}
Pencil
write() {
//leadImpl
}
Writer
write()
Square
Shape
There are two types of shape (Circle, Square)
Circle
40. CVA Exercise (2)
Pen
write() {
//inkImpl
}
Pencil
write() {
//leadImpl
}
Writer
write()
Square
Shape
print()
Each shape can print itself on different writers
Circle
43. Starbucks
Create a software for cashier and barista
A program accepts order from user
Retrieve cost based on the order
A program shows the barista what to do
44. Starbucks
A program creates
order from user
Retrieve cost based
on the order
A program shows
the barista what to
do
order = user.createOrder()
cost = order.getCost()
inst = order.whatToDo()
45. Starbucks
Select Size of cup (S,M,L)
(S) Cup -> Coffee
(M) Cup -> Coffee x 2
(L) Cup -> Coffee x 3
S = 100, M = 120, L = 150
order = user.createOrder() {
selectSize()
}
cost = order.getCost()
inst = order.whatToDo()
46. Starbucks
Select Size of cup (S,M,L)
(S) Cup -> Coffee
(M) Cup -> Coffee x 2
(L) Cup -> Coffee x 3
S = 100, M = 120, L = 150
M
coffee() {
//2
}
price() {
//120
}
Cup
coffee()
price()
S
coffee() {
//1
}
price() {
//100
}
L
coffee() {
//3
}
price() {
//150
}
47. Starbucks
order = user.createOrder() {
selectSize()
}
cost = order.getCost() {
order.getCup().getPrice()
}M
coffee() {
//2
}
price() {
//120
}
Cup
coffee()
price()
S
coffee() {
//1
}
price() {
//100
}
L
coffee() {
//3
}
price() {
//150
}
Order
55. Starbucks (v2)
Select Coffee Type (Hot/Cold) [ cold serve with ice ]
Select Size of cup (S,M,L)
(S) Cup -> Coffee
(M) Cup -> Coffee x 2
(L) Cup -> Coffee x 3
S = 100, M = 120, L = 150, Hot/Cold = Same price
56. Starbucks (v3)
Select Coffee Type (Hot/Cold) [ cold serve with ice ]
Americano [ Coffee + Water ]
Cappuccino [ Coffee + Milk + Whip the milk ]
Latte [ Coffee + Milk ]
Select Size of cup (S,M,L)
(S) Cup -> Coffee
(M) Cup -> Coffee x 2
(L) Cup -> Coffee x 3
S = 100, M = 120, L = 150, Hot/Cold = Same price, Latte +10, Cappucino + 20