mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
Don't ruin the complexity of your interface with checking.
This commit is contained in:
parent
fe811ed63a
commit
937488887f
|
@ -749,7 +749,7 @@ The date is validated twice (by the `Date` constructor) and passed as a characte
|
||||||
##### Example
|
##### Example
|
||||||
|
|
||||||
Excess checking can be costly.
|
Excess checking can be costly.
|
||||||
There are cases where checking early is dumb because you may not ever need the value, or may only need part of the value that is more easily checked than the whole.
|
There are cases where checking early is dumb because you may not ever need the value, or may only need part of the value that is more easily checked than the whole. Similarly, don't add validity checks that change the asymptotic behavior of your interface (e.g., don't add a `O(1)` check to an interface with an average complexity of `O(1)`).
|
||||||
|
|
||||||
class Jet { // Physics says: e*e < x*x + y*y + z*z
|
class Jet { // Physics says: e*e < x*x + y*y + z*z
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user