by koboll · 7y ago · 0 comments
>gives cryptic names for variables, or at best not self-explanatory
sure a big one. It's part of a category of small decisions that dramatically increase cognitive load when accumulated. Along with it:
>Passing many arguments into functions with names that have no relevance to their role inside the function, so you constantly have to look up which argument maps to which function param
>Needlessly reorganizing data structures or renaming variables so that it becomes more difficult to reason about the flow of data
Naming things isn't just the hardest problem in programming, it's also the quickest way to piss off your peers if you're lazy about it.
MSA: MSA subject analysis
It's pretty hard to go through scripts older than a year and understand what's going on.if(!FeatureNotDisabled){ .... }
It drives me absolutely bonkers!
Feature1Disabled=False
Feature2Disabled=True
Feature3Disabled=False
Instead of using feature flags to enable a feature, he used feature flags to disable features. He was very consistent and the logic is all correct, simply inverted.
Yes, `if (!FeatureEnabled){ ... }` would be clearer.
It's only a double negative (“disabled” is affirmative, though the same sense can be communicated by the single negative “not enabled”.)
class TheRpcThing
{
object TheRpcThingHost
object TheRpcThingHostTimer
class TheRpcThingValidationException
{
object TheRpcThingHostValidationException
object TheRpcThingHostValidationExceptionErrorMessage
object TheRpcThingHostValidationExceptionErrorMessageFormatter
}
}
The cognitive cost of reading a bunch of previously-unseen code, which has an accumulation (the perfect word for this kind of thing) of the above can be so frustrating.Generally, every capital letter indicates another hierarchical relationship from left-to-right. Usually these are implementation details that shouldn't be publicly exposed, or at least could be separated out/encapsulated better in a different object/function structure.
Obviously it's a rule-of-thumb and there are exceptions, but I've found this works pretty well.