| Basket | Weight |
|---|---|
| 1 | 35 |
| 2 | 35 |
| 3 | 50 |
| 4 | 40 |
| Weight | |
|---|---|
| 35 | |
| +35 | |
| +50 | |
| +40 | |
| Sum | 160 |
//Element Type: OrangeBasket weightSum = 0 Loop through baskets weightSum += basket.getWeight() Return weightSum
Count: 4 Sum: 160 Average: 40 Min: 35 Max: 50 Standard Deviation: 6.1
//Element Type: OrangeBasket weightSum = 0 Loop through baskets weightSum += basket.getWeight() Return weightSum
| Code | Action |
|---|---|
| If mostly specific | Then code (solution) is specific/unique and it will not be solve the other problems -- that happens) |
| If minimally specific | Then we'll look for generalization opportunities |
//Element Type: OrangeBasket weightSum = 0 Loop through baskets weightSum += basket.getWeight() Return weightSum
//Element Type: OrangeBasket weightSum = 0 Loop through elements weightSum += anOrangeBasket.getWeight() Return weightSum
//Element Type: OrangeBasket
weightSum = 0
Loop through elements
weightSum += anOrangeBasket.getWeight()
Return weightSum
//Element Type: OrangeBasket
weightSum = 0
Loop through baskets
weightSum += basket.getWeight()
Return weightSum
String name = "Foo"; name.getWeight();
//Element Type: OrangeBasket weightSum = 0 Loop through baskets weightSum += basket.getWeight() Return weightSum
//Type: OrangeBasket weightSum += anOrangeBasket.getWeight()
//Type: Weighable weightSum += aWeighable.getWeight()
public interface Weighable {
public int getWeight();
}
//Element Type: Weighable weightSum = 0 Loop through weighables weightSum += aWeighable.getWeight() Return weightSum
public class Suitcase implements Weighable
public interface Weighable {
public int getWeight();
}
@Override public int getWeight() { //Return actual weight here //Coder's choice }