Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is ‘power-to-weight ratio’ of an API?

Tags:

java

api

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
like image 214
卢声远 Shengyuan Lu Avatar asked Aug 30 '10 08:08

卢声远 Shengyuan Lu


People also ask

What does power-to-weight ratio mean?

Power-to-weight ratio is a measurement of actual performance of any engine or power source. It is also used as a measurement of performance of a vehicle as a whole, with the engine's power output being divided by the weight (or mass) of the vehicle, to give a metric that is independent of the vehicle's size.

What is the power-to-weight ratio formula?

Your power-to-weight ratio can be calculated as watts (W) divided by your body weight in kilograms (kg), expressed as W/kg.

What is a 1 1 power-to-weight ratio?

The Koeniggsegg One:1 has a power-to-weight ratio of 1:1, meaning that for every kilogram it weighs, it generates 1 horsepower.

What is the significance of the power-to-weight ratio in aviation?

The thrust-to-weight ratio and wing loading are the two most important parameters in determining the performance of an aircraft. For example, the thrust-to-weight ratio of a combat aircraft is a good indicator of the maneuverability of the aircraft. The thrust-to-weight ratio varies continually during a flight.


1 Answers

I'd interpret "conceptual weight" as the number of abstract concepts you have to learn and understand to use the API. Concepts usually map to public classes, while classes that are not public add to the bulk but not to the conceptual weight.

So if you put it technically, an API has a high conceptual weight if a typical client of the API has to explicitly use a lot of classes belonging to the API to work with it.

"good power-to-weight ratio" then means the API should use as few public classes as possible to offer as much functionality as possible. That means an API should:

  • Not add concepts or abstractions of its own that are not present in the domain
  • For complex domains, offer shortcuts to the most commonly needed functionality that allows a typical user to bypass the more complex parts of the domain
like image 76
Michael Borgwardt Avatar answered Oct 12 '22 19:10

Michael Borgwardt