Re:Greppability is an underrated code metric
by iudqnolq on Tuesday September 03, 2024 @06:28AM
(#41433358)
I like using l for logger and db for database client/pool/handle even if there's a wider scope. And if the bulk of a file is interacting with a single client I might call that c.
Re:Greppability is an underrated code metric
by marcosdumay on Tuesday September 03, 2024 @10:37AM
(#41435397)
> that is true of almost any language
You'd be surprised how often language-local cultures break that rule on either side. And a few times it's even an improvement.
Re:Greppability is an underrated code metric
by lanstin on Tuesday September 03, 2024 @10:47AM
(#41435484)
Zipf's law, right - these rules are a formalization of our brain's functionality with language.
Of course, with enough code, someone does everything.
Re:Greppability is an underrated code metric
by kazinator on Tuesday September 03, 2024 @11:22AM
(#41435843)
E.g. food and art are very important in Japan, so stomach is i and a drawing/painting is e.
Re:Greppability is an underrated code metric
by BrandoElFollito on Tuesday September 03, 2024 @01:22PM
(#41437083)
Food is very very important in France so we call it nourriture :)
The convention, not just in Go, is that the smaller the scope, the smaller the variable reference.
So, sure, you're going to see single-letter variables in short functions, inside short block scopes, etc, but that is true of almost any language.
I haven't seen single-letter variables in Go that are in a scope that isn't short.
Of course, this could just mean that I haven't seen enough of other peoples Go source.