In Bloch’s presentation, he said designer should look for good power-to-weight ratio for API. Moreover, he also stressed that ‘Conceptual weight more important than bulk’. I guess the weight is for ‘Conceptual weight’, bulk is for number of methods of a class.
But I couldn’t understand what ‘Conceptual weight’ is, what ‘power-to-weight ratio’ is. Welcome to any explanation!
Bloch gave an example: List.subList()
has good 'power-to-weight ratio'. If clients wants to know an index of a sub list, he doesn't need to call a low 'p2w ratio' method indexOfSubList(a,b,e)
, instead, he could call List.subList(a,b).indexOf(e)
. Bloch thought this is 'power-to-weight ratio'.
Origin:
API Should Be As Small As Possible But No Smaller
- API should satisfy its requirements
- When in doubt leave it out
- Functionality, classes, methods, parameters, etc.
- You can always add, but you can never remove
- Conceptual weight more important than bulk
- Look for a good power-to-weight ratio