Naming
Caching
Off By One Errors
What to Measure:
Input/Output:
Number of Units
Before/After state of the process
Process:
How long did it take
How much processing time is used
How much memory did it use
How much bandwidth was used
Output:
How many were successful
How many failed
Why did they fail
Which failed
When there are many Input > Process > Output, then you have a funnel.
if ($ent === null) {printf("Unable to load ent %d", $ent_id);exit(1);}
Sometimes we need to pair two variables together to represent a single datatype. For example tuple(MetricID, Partner)
which tells us that this represents the MetricID
for a given Partner
.
You may want to consider 2 data structures for this:
Metric(MetricID)
MetricPartner(Metric/MetricID, Partner)
It is easier moving from a data structure that manages one data type, to a data structure that manages 2.
Consider having a function in Metric
which takes in a Partner
and returns a MetricPartner
. For example:
$metric = new Metric($metric_id);$metric_partner = $metric->withPartner($partner);
How many lines of code are being added?
Are there alerts on highly sensitive parts of the codebase?
Pros:
More flexibility in matching strings
Regexes don't require precise string matching
Can easily match more than one string, for example to match all branches where node8
work is done: /\.*node8/
Cons:
Regexes are slightly more time consuming
For example:
regex.matches(input)
vs
inputs.split(',').some((input) => input === expected);
​