by nv-vn · 9y ago · 0 comments
Also, notice how R, G, and B have a very clear meaning when put near "color"? Context is a thing our brain manages very well.
(let ((copy (copy-list list)))
(list copy 'copy 'let))
A 13 syllabic verse (7+6, with caesura)(but yes, you are right)
What has bitten me many times is accidentally overwriting a builtin function like max or len in python and then scratching my head about the strange errors that result from this.
Doctor, it hurts when ...
This is not an easy problem to solve. For every "easy" example of a good name, one readily encounters an easy counterexample that renders the name ambiguous or unfit for a particular purpose.
Names must necessarily include context to be meaningful. If "name" is an unambiguous identifier in your scope and it's obvious what it does, great! Don't fix what isn't broken. But when you catch ambiguity or uncertainty, revisit the code, so future developers have an easier time understanding what you meant.
And this digs out a tangential problem - that often, "name" is as specific as you can get (or at least as specific as you should get) - http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-b....
When you're inside a function, dealing with very limited scoped variables, people get that.
People also 'get' attributes of classes and can grasp that context.
You know what's rational - that the 'length' of an array is just called 'length' :)
Anything else would be missing the point.
I have learned over many years that longer, highly readable and descriptive names make life extremely easier in the long run, at the expense of a few extra characters to type.
For example, in the case of "name" there are typically many different things that need a "name" in the same context. First name, last name, etc. "name" by itself (and other short names) is honestly asking for lots of headaches in the long run.
If you write SQL, you can disambiguate by table name prefix. If you iterate over result sets for example in python, you can easily be more specific on tuple destructuring time ("for personName, carName in ...").
When defining a table "Person", I consider it bad style to prefix all column names with "person". Btw this overzealous disambiguation falls flat as soon you do a self-join.
Is it "first name", "last name" or "full name"?
Is it a person's full name? legal name? first name? last name? nick name? desired call name? a company name? the name (alias) of the stored address?
http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-b...
Following this line of thinking, communication is impossible because everything is ambiguous.
I will now end my concern about being downvoted and get a life. The discussion culture in this thread is mad.