> For the complete documentation index, see [llms.txt](https://edsonha.gitbook.io/my-gitbook/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://edsonha.gitbook.io/my-gitbook/refactoring/code-smells/speculative-generality.md).

# Speculative Generality

```javascript
//Problem:
class Delivery {
  rating(aDriver) {
    return moreThanFiveLateDeliveries(aDriver) ? 1 : 5;
  }
  moreThanFiveLateDeliveries(aDriver) {
    return aDriver.numberOfLateDeliveries > 5;
  }
}


//**Solution**:
class Delivery {
  rating(aDriver) {
    return aDriver.numberOfLateDeliveries > 5 ? 1 : 5;
  }
}
```
