I'm sure it would have been a great demonstration of CTWTA if the author hadn't fucked it up by not knowing what gear inches are.
You absolutely may not replace gear_inches with size_inches since the former is a term of art.
The whole problem was that the class wasn't named correctly. It isn't a gear, since those don't have rims, it's a gearing. A gearing is what is made of a chainring, cog, and wheel. And a gearing has a specific ratio, development, and gear inches.
PS: I'm sure there is an interesting follow-up about developers having to understand the business side of stuff to be able to CTWTA. Because it seems here the problem is not just calling things what they are, but what happens when the next person comes along and doesn't have the necessary background to recognize what the name means.
Damn it. Fair point. I'll have to update the article. But also to be fair, why should I know what gear inches are? Why should anyone? The author shouldn't have used an example which requires you to know something that's not common knowledge.
It's also frustrating that the name Gear was used for what is apparently a Gearing. And I wonder: does gearing.gear_inches make sense? Maybe it does, maybe it doesn't. I don't have the background to know. I'll have to research. Once again, bad example to use in a book.
tbf, while it doesnt work amazing as an example, whoever working with this code either should know what it is or should have quick access to someone who does
It's also frustrating that the name Gear was used for what is apparently a Gearing.
"Gear" is also a correct term for this. The problem is that the word "gear" has multiple meanings that are relevant in this context. From Merriam-Webster:
gear noun
[...]
6a(2): a toothed wheel
6b: one of two or more adjustments of a transmission (as of a bicycle or motor vehicle) that determine mechanical advantage, relative speed, and direction of travel
You will recognize definition 6b from phrases like "first gear," "second gear," "shift gears," and so on.
It's a fair argument that the example requires too much specific knowledge to be a good example.
It seems they used gear, the same way one might when talking about a stick-shift car. (first gear, second gear, etc.) But it does carry the confusion of talking about an individual gear. I think gearing would have been less ambiguous.
Incidentally, your cumulative misunderstandings do bring you to a relatively correct answer. Because describing the result as the size of a single gear should be quite close to describing it as the size of the wheel of a penny-farthing.
Penny-farthings... Imperial units are something else...
I work with someone that is widely regarded as an incompetent junior dev that's somehow got the mid-level title, he's so bad he must be related to Julius. I wish I could literally print this into a book and smack him around the head with it.
Button that makes new customer? nwCuBtn, newCustButn
Function that takes a loyalty card who's name is synonymous with Honey? Name the argument hone because that one letter being saved is important.
A database column? inclusionsormaybeexclusionscustomerexpiredrecent
One of the arguments I've seen for some web development libraries is "because naming things is hard" and so I wondered when a designer/dev is talking to a peer and trying to sort out where a problem is how do they communicate?
"Oh I see the problem, it's from the flex flex-col overflow-hidden rounded-xl border border-gray-200 bg-white shadow-sm transition-shadow hover:shadow-md dark:border-gray-800 dark:bg-gray-900 component"
or do they still dead-name them "Oh I see the problem, it's the card component" or "it's card variant A" or "card CTA with description"
The problem with naming things and calling them what they are spans a host of problems related to context and domain specific knowledge. What is something generally (colloquially) vs what do the experts in that domain call it. I.E. drug vs medication, doctor vs prescriber, patient versus person, gear vs sprocket, and so on. Somewhere you need a system and a glossary of terms that are agreed on and most often you don't have that sort of contract anywhere. Naming conventions often come up on the fly and even when they are agreed upon upfront you run into exceptions that don't get discussed or documented anywhere.
I can relate but can't help you Devs simply pickup things that they were taught In the earliest days of programming they're taught programs that have small variable names just to keep the program visually small so they don't get overwhelmed and later they pick that short variable naming as a convention and use it everywhere
It made sense at that time since it took less letters to write or type it was faster to type and write and score more marks
But later when you go write code for production and start maintaining it on long runs....
only then you start to realise your big codebase at work has become ambiguous, now your choice of names doesn't make sense anymore, you're a day short shipping a new feature that you've promised a week ago but you're at 6th day making non-sense commits "chore: fixing variable names, added naming conventions in contribution.md etc."
And that is when you're the only maintainer of the project now just imagine you have a team of 5 then you're fixated to their un-told naming schemes and just keep pushing and you'll never get to think on such a trivial matters
Yeah....
I guess it's a teaching problem... No one taught these things...
Just gonna copy and paste my response from the ruby subreddit here:
I don't understand... Why is this method an exception?
def ratio
chainring / cog.to_f
end
Later, in the "fixed" version, this becomes:
def gear_ratio
chainring_tooth_count / cog_tooth_count.to_f
end
What the hell is f? I genuinely have no idea.
How do we get through this entire article and never address this!?
Edit: I just found out it's a built-in method for Ruby that converts to floating point. I don't use this language-- I just like reading all the programming subreddits. To me, if you have this mindset, then I can't understand why you would use a language that doesn't cohere to your desires. Why not call floating point numbers what they are?
31
u/jechase 5h ago
There are only two hard problems in computer science:
41
u/Lke590 5h ago edited 4h ago
I'm sure it would have been a great demonstration of CTWTA if the author hadn't fucked it up by not knowing what gear inches are.
You absolutely may not replace
gear_incheswithsize_inchessince the former is a term of art.The whole problem was that the class wasn't named correctly. It isn't a gear, since those don't have rims, it's a gearing. A gearing is what is made of a chainring, cog, and wheel. And a gearing has a specific ratio, development, and gear inches.
PS: I'm sure there is an interesting follow-up about developers having to understand the business side of stuff to be able to CTWTA. Because it seems here the problem is not just calling things what they are, but what happens when the next person comes along and doesn't have the necessary background to recognize what the name means.
6
u/ReallySuperName 1h ago edited 1h ago
I work with someone that is widely regarded as an incompetent junior dev that's somehow got the mid-level title, he's so bad he must be related to Julius. I wish I could literally print this into a book and smack him around the head with it.
nwCuBtn,newCustButnhonebecause that one letter being saved is important.inclusionsormaybeexclusionscustomerexpiredrecentIt's hell.
2
u/nhavar 1h ago
One of the arguments I've seen for some web development libraries is "because naming things is hard" and so I wondered when a designer/dev is talking to a peer and trying to sort out where a problem is how do they communicate?
"Oh I see the problem, it's from the flex flex-col overflow-hidden rounded-xl border border-gray-200 bg-white shadow-sm transition-shadow hover:shadow-md dark:border-gray-800 dark:bg-gray-900 component"
or do they still dead-name them "Oh I see the problem, it's the card component" or "it's card variant A" or "card CTA with description"
The problem with naming things and calling them what they are spans a host of problems related to context and domain specific knowledge. What is something generally (colloquially) vs what do the experts in that domain call it. I.E. drug vs medication, doctor vs prescriber, patient versus person, gear vs sprocket, and so on. Somewhere you need a system and a glossary of terms that are agreed on and most often you don't have that sort of contract anywhere. Naming conventions often come up on the fly and even when they are agreed upon upfront you run into exceptions that don't get discussed or documented anywhere.
4
u/rekkonnect 6h ago
I could use half the rant and double the reasoning of why people don't apply CTWTA, and it's just laziness
And really we have bigger fish to catch than to masturbate over how good CTWTA is when applied
2
u/_choam_ 4h ago
Either call something what it is, or use a one letter name when calling something what it is is more confusing.
1
u/stools_in_your_blood 2h ago
It has always bothered me when people refer to an email address as an "email", as in "what's your email?" It's like calling a phone number a phone.
1
u/maelstrom071 56m ago
Very good piece, and a rule I generally try to follow
1
u/PratikVR 13m ago
I can relate but can't help you Devs simply pickup things that they were taught In the earliest days of programming they're taught programs that have small variable names just to keep the program visually small so they don't get overwhelmed and later they pick that short variable naming as a convention and use it everywhere
It made sense at that time since it took less letters to write or type it was faster to type and write and score more marks
But later when you go write code for production and start maintaining it on long runs....
only then you start to realise your big codebase at work has become ambiguous, now your choice of names doesn't make sense anymore, you're a day short shipping a new feature that you've promised a week ago but you're at 6th day making non-sense commits "chore: fixing variable names, added naming conventions in contribution.md etc."
And that is when you're the only maintainer of the project now just imagine you have a team of 5 then you're fixated to their un-told naming schemes and just keep pushing and you'll never get to think on such a trivial matters
Yeah....
I guess it's a teaching problem... No one taught these things...
-1
u/jessepence 2h ago
Just gonna copy and paste my response from the ruby subreddit here:
I don't understand... Why is this method an exception?
Later, in the "fixed" version, this becomes:
What the hell is
f? I genuinely have no idea.How do we get through this entire article and never address this!?
Edit: I just found out it's a built-in method for Ruby that converts to floating point. I don't use this language-- I just like reading all the programming subreddits. To me, if you have this mindset, then I can't understand why you would use a language that doesn't cohere to your desires. Why not call floating point numbers what they are?