« Back to Index
[Good Naming Strategy]
View original Gist on GitHub
Tags: #documentation #docs #guides #tutorials #reference #explanation #writing #naming #go #golang
Good Naming Strategy.md
Reference: http://journal.stuffwithstuff.com/2016/06/16/long-names-are-long/
Choosing a Good Name
A name has two goals:
- It needs to be clear: you need to know what the name refers to.
- It needs to be precise: you need to know what it does not refer to.
After a name has accomplished those goals, any additional characters are dead weight.
Tips
Here are some tips to help you…
- Omit words that are obvious given the type (e.g. ❌
var fooString string
).
- Omit words that don’t disambiguate the name (e.g. ❌
finalMostDangerousMonster
vs ✅ boss
).
- Omit words that are known from the surrounding context (e.g. ❌
class HolidaySale: _HolidayRebate = 123
).
- Omit words that don’t mean much of anything (e.g. ❌
class WaffleObject
vs ✅ class Waffle
).
Golang Tips
https://talks.golang.org/2014/names.slide