Contents

The Tell Dont Ask Principle

Contents

Asking

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
if steeringWheel < 0 {
    turnLeft()
} else if steeringWheel > 0 {
    turnRight()
}

func turnLeft() {
    ...
}

func turnRight() {
    ...
}

Telling

1
2
3
4
5
6
7
8
9
type car struct {
    ...
}

func (c car) turn() string {
    ...
}

car_1.turn()