Fun fact: When printing with movable type began, printers would travel with large "type cases" containing the small wood or metal blocks with glyphs on them. The ones the used frequently were kept in the lower half of the case, in easy reach. That's where the terms "lowercase" and "uppercase" come from.
Go Naming Conventions: A Practical Guide
61–70 of 77 posts
Re: Go Naming Conventions: A Practical Guide
#62Earlier quoted context omitted.
Using a linter doesn't get you noticed by leadership and net you a promo.
Sure it does, just say you "established org-wide coding standards and drove adoption of automated linting tooling, reducing review friction and enforcing style consistency at scale" in your assessment.
Re: Go Naming Conventions: A Practical Guide
#63Earlier quoted context omitted.
I've felt strongly for a while now that abbreviations should be "lossless" in order to be useful; it should be unambiguous now get back to the unabbreviated form. For whatever reason, people seem to love trying to optimize for character count with abbreviations that actually make things more confusing (like `res` in a context where it might mean either "response" or "result). I just don't get the obsession with terse…
> and any decent formatter will split up long lines Any decent editor can wrap long lines on demand. But it's even better not to have to do either of those if not necessary. > I've felt strongly for a while now that abbreviations should be "lossless" in order to be useful This is how we got lpszClassName. The world moved away from hungarian notation and even away from defining types for variables in some contexts (au…
Re: Go Naming Conventions: A Practical Guide
#64Allowing Unicode characters, then stating best practice is to stick with ASCII, is weird. (Go is not alone in this practice.) Unicode identifiers have a host of issues, such as some characters have no case distinction, some have title-case but not uppercase, some "capitalize" the last letter in a word and not the first (Hebrew has five "final form" letters), etc. Does Go specify the meaning (exported or not) if a let…
Re: Go Naming Conventions: A Practical Guide
#65Earlier quoted context omitted.
If your loops are so long you can't fit them on one screenfull you have much more fundamental issues.
person.Age is easier to understand than p.Age regardless of the loop size.
Re: Go Naming Conventions: A Practical Guide
#66Allowing Unicode characters, then stating best practice is to stick with ASCII, is weird. (Go is not alone in this practice.) Unicode identifiers have a host of issues, such as some characters have no case distinction, some have title-case but not uppercase, some "capitalize" the last letter in a word and not the first (Hebrew has five "final form" letters), etc. Does Go specify the meaning (exported or not) if a let…
Of course, Unicode can be abused, but ASCII isn’t completely free of that either. (Maybe it tickles your fancy to name a variable _o0O0o_ or l1lIl1lIl1lIl1l.) If your native script doesn’t have upper and lower case, compromises may have to be made. We have to trust programmers to use good judgement.
Re: Go Naming Conventions: A Practical Guide
#67Allowing Unicode characters, then stating best practice is to stick with ASCII, is weird. (Go is not alone in this practice.) Unicode identifiers have a host of issues, such as some characters have no case distinction, some have title-case but not uppercase, some "capitalize" the last letter in a word and not the first (Hebrew has five "final form" letters), etc. Does Go specify the meaning (exported or not) if a let…
It’s bad to disallow non-ASCII characters when programming for non-English business domains. The domain vocabulary often doesn’t translate well to English, or you need a glossary for someone familiar with the business domain to know which English term is supposed to mean which native business term. It’s just a pain. Conversely, transliterating the native term in ASCII can introduce ambiguities or be awkward or just p…
Re: Go Naming Conventions: A Practical Guide
#68Allowing Unicode characters, then stating best practice is to stick with ASCII, is weird. (Go is not alone in this practice.) Unicode identifiers have a host of issues, such as some characters have no case distinction, some have title-case but not uppercase, some "capitalize" the last letter in a word and not the first (Hebrew has five "final form" letters), etc. Does Go specify the meaning (exported or not) if a let…
It’s bad to disallow non-ASCII characters when programming for non-English business domains. The domain vocabulary often doesn’t translate well to English, or you need a glossary for someone familiar with the business domain to know which English term is supposed to mean which native business term. It’s just a pain. Conversely, transliterating the native term in ASCII can introduce ambiguities or be awkward or just p…
Re: Go Naming Conventions: A Practical Guide
#69Earlier quoted context omitted.
Long lines make reading rhythm uncomfortable (long jumps, prolonged eye movements) and long words make the text too dense and slow down the reading. It’s bad typography. I have heard an idea that a good variable should be understood by just reading its name, out of context. That would make “ProductIndex” superior to “i”, which doesn't add any clarity.
I think this may be related to how people read code. You have people who scan shapes, and then you have people who read code almost like prose. I scan shapes. For me, working with people who read code is painful because their code tends to to have less clear "shapes" (more noise) and reads like more like a verbal description. For instance, one thing I've noticed is the preference for "else if" rather than switch stru…
I agree with this, but can't see how this applies to variable naming. Variable names can be too long, sure, but in my opinion, very short non-obvious variable names also make scanning and reading harder since they are not familiar shapes like more complete words. Additionally, when trying to understand more deeply, you have to stop and read code more often if variable's meaning is not clear.
That said, 1-2 char variable names work well in short scopes, like in some lambda, or when using 'i' for an index in a loop (nested loops would depend on situation), but those are an exception.
Like always, this is probably subjective too. And well-organized codebase probably helps to keep functions shorter, but there's often not much I can do about the existing codebase having overgrown functions all over.
Re: Go Naming Conventions: A Practical Guide
#70Earlier quoted context omitted.
It’s bad to disallow non-ASCII characters when programming for non-English business domains. The domain vocabulary often doesn’t translate well to English, or you need a glossary for someone familiar with the business domain to know which English term is supposed to mean which native business term. It’s just a pain. Conversely, transliterating the native term in ASCII can introduce ambiguities or be awkward or just p…
I believe https://imgur.com/dN9Nz3h is the canonical example of why full Unicode support is maybe not desirable.
class pppp {
func ppp(_ c: Int, m: Int) -> Int {
return c + m
}
}
var b = 3
var s = b + 2
var p = pppp()
print(p.ppp(b, m: s))