Skip to content

"Grains" Simpler method names - #1779

Merged
FridaTveit merged 4 commits into
exercism:masterfrom
ViralTaco:master
Nov 1, 2019
Merged

FridaTveit merged 4 commits into
exercism:masterfrom
ViralTaco:master

Conversation

@ViralTaco

Copy link
Copy Markdown
Contributor

Hi,

Following the issue #1778 I thought it'd be better to discuss the issue over some concrete code.
This is just changing the name of the methods to make them simpler.

Thank you for your time.


Reviewer Resources:

Track Policies

@FridaTveit FridaTveit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As briefly discussed on the issue you raised, in my opinion the existing method names are more descriptive than the ones you want to change them to. I see your argument and am happy to discuss it further, as long as you're willing to discuss it in a polite manner where you acknowledge that other people's opinions are valid even if you don't agree with them. Especially as this is to do with naming which is a quite subjective issue 🙂

@ViralTaco

ViralTaco commented Nov 1, 2019 •

Copy link
Copy Markdown
Contributor Author

I understand that others opinion are valid. You didn't give me an opinion to work with.
You said the names currently in the code are more descriptive. It's true, they are more verbose but if that's the standard then why stop there? You can go in a lot more detail.

My argument is that there is no additional information in the longer method name. "Number" is vaguer than BigInteger (which the method returns) "Grains" is the name of the class and "of" can be omitted since "grains" can.
It's a bit like calling Integer.parseInt "Integer.getNumberFromParsedString" it's more descriptive but in the context in which it is used it doesn't provide the reader with any more information than they already had, don't you agree?

EDIT: actually grainsOnSquare could be fine just in case someone uses a bad variable name for the object but if you're codding against that you're, in my opinion, fixing the wrong problem.

@FridaTveit

Copy link
Copy Markdown
Contributor

I gave you the opinion that the existing names are more descriptive 🙂Or to paraphrase (and to answer your question of "why stop there"), I don't think the names you were suggesting were descriptive enough. And also, descriptive is not the same as verbose. You can have a very long name that's not at all descriptive, and you can have a short name that's very descriptive 🙂

One thing is the context where you're calling the method. In that case, as you've already mentioned, naming the variable anything other than grains could make the intention of the method unclear.

There's also the context where you're looking at the method in the class where it's defined. I think you should be able to tell at a glance what that method does, and just onSquare doesn't really tell me that.

I do agree that compute can probably be omitted. I'd probably prefer for the method to be named numberOfGrainsOnSquare. But I can see the argument for omitting numberOf so I'd be happy to approve renaming it to grainsOnSquare (and grainsOnBoard) 🙂

@FridaTveit FridaTveit left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks 🙂 And thanks for listening to my comments and changing your tone 🙂

@FridaTveit
FridaTveit merged commit e14534e into exercism:master Nov 1, 2019
@ViralTaco

Copy link
Copy Markdown
Contributor Author

Looks great, thanks 🙂 And thanks for listening to my comments and changing your tone 🙂

No problem, sorry for the tone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants