January 2020
Intermediate to advanced
548 pages
13h 36m
English
Names that are too short are usually employing either program-specific knowledge or domain-specific knowledge that may not generalize well to the audience of the code. A lone programmer may think it reasonable to write the following code:
function incId(id, f) { for (let x = 0; x < ids.length; ++x) { if (ids[x].id === id && f(ids[x])) { ids[x].n++; } }}
We are able to discern the fact that it is related to IDs and its purpose is to conditionally increment a specific object's n property within the ids array. Therefore, it is possible to discern what it is doing on a functional level, but its meaning and intent are difficult to grasp. The programmer has used single-letter names (f, x, n) and has also employed an abbreviated ...
Read now
Unlock full access