liveBook · Manning

Usability metric

As explained in 100 C++ Mistakes and How to Avoid Them

Effectiveness is a measure of how well language features are applied for their intended purposes to reduce development effort.

Effectiveness measures how well language features serve their intended purposes. In practice, it means choosing compact, appropriate expressions that save development time, improve productivity, and often support correctness. section 1.2.3

Mistake: duplicating behavior. Separate constructors or methods may repeat the same knowledge, increasing cognitive load and allowing implementations to diverge. Reduce behavior implementations by identifying a minimal basis from which the others can be built. section 7.5

Centralize a Cylinder's behavior

A Cylinder with three constructors duplicates radius, height, area, and volume calculations. A safer design initializes radius and height once through init, then derives basearea and volume from those values. One calculation change no longer requires updating several constructors.

Mistake: underusing expressions. An if/else statement computes a result through control flow, while a ternary expression directly produces a value. Use the shorter form when it clarifies a value computation, without forcing every conditional into an expression. section 12.5

Compute an evenness label directly

Repeated if/else branches print either “even” or “odd.” The cleaned-up form places (isEven(n) ? "even" : "odd") directly in the output expression, removing duplicated output structure while keeping the decision visible.

Separate short-circuit cases

For mean, handle no values by throwing and one value by returning immediately. Leave the remaining path for the main summation, so base cases do not obscure the computation with unnecessary else nesting. section 12.6

How 100 C++ Mistakes and How to Avoid Them covers it

How deep it goes
Defines the metric, then works through duplication, ternary expressions, and short-circuit control flow without formal measurement.
Examples
Uses Cylinder constructors, arithmetic operations, evenness output, and mean calculation to contrast duplicated or obscured code with focused alternatives.
What you can do after
Diagnose duplicated or unnecessarily verbose C++ code and replace it incrementally with focused implementations and clearer expressions.
How it connects
Connects effectiveness with correctness, readability, programmer productivity, code duplication, and the DRY principle.

Also explained in

Compare how 2 books explain usability metric →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of 100 C++ Mistakes and How to Avoid Them. The section links point to the parts of the book it draws on.