Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename 'foo' function to 'simple' in flow docs #2078

Merged
merged 1 commit into from
Jul 16, 2020
Merged

Rename 'foo' function to 'simple' in flow docs #2078

merged 1 commit into from
Jul 16, 2020

Conversation

elizarov
Copy link
Contributor

@elizarov elizarov commented Jun 3, 2020

The name 'foo' might be hard to get for novice developers. It is really hard to find a "meaningful" name for all examples in the docs, so this is simply a consistent solution. The alternative is to something like "simpleFlow", but adding a "Flow" suffix to the name implicitly condones Hungarian notation, which is not aligned with Kotlin coding style.

The name 'foo' might be hard to get for novice developers. It is really hard to find a "meaningful" name for all examples in the docs, so this is simply a consistent solution. The alternative is to something like "simpleFlow", but adding a "Flow" suffix to the name implicitly condones Hungarian notation, which is not aligned with Kotlin coding style.
@elizarov elizarov requested a review from qwwdfsad June 3, 2020 09:25
@elizarov
Copy link
Contributor Author

elizarov commented Jun 3, 2020

cc @LouisCAD

@LouisCAD
Copy link
Contributor

LouisCAD commented Jun 3, 2020

The alternative is to something like "simpleFlow", but adding a "Flow" suffix to the name implicitly condones Hungarian notation, which is not aligned with Kotlin coding style.

Suffixing a symbol for the sake of an example isn't endorsing Hungarian notation to me.

In application code, I often suffix the symbols of type Flow because I'll need to disambiguate with the parameter name of the lambda passed to collect.
Example:

val isOnFlow = whatever().distinctUntilChanged()
isOnFlow.collectLatest { isOn -> doSomeStuff() }

compared to:

val isOn = whatever().distinctUntilChanged()
isOn.collectLatest { isOn -> doSomeStuff() }

That's why I personally prefer someFlow() or exampleFlow() to simple().

I'm also not a fan of simple() because of the meaning of the word "simple", that I find not relevant in this context, while "some" doesn't hint at anything special and directs attention to the rest (here, the operations performed on the flow itself).

Of course, for the examples where the fact that the flow is simple is relevant (e.g. showing how to make a simple flow with the most basic builder, flow { }), I think it makes sense to have the word "simple" there, although I'd lean towards simpleFlow() rather just simple().

That's ony my point of view. That's alright if you disagree.
If you think some points I made are not right, I'm curious to knwo which ones and why.

Also, maybe we can ask other developers on Kotlin's Slack, or developers in this Twitter thread for example (cc @ahinchman1) to get other angles and confidence in the chosen naming?

@LouisCAD
Copy link
Contributor

LouisCAD commented Jun 8, 2020

A few other namings that I (personally) find alright and less confusing than simple: someNumbers() & numbers(). Thought about this after this short Slack thread.

Copy link
Collaborator

@qwwdfsad qwwdfsad left a comment

Choose a reason for hiding this comment

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

but adding a "Flow" suffix to the name implicitly condones Hungarian notation, which is not aligned with Kotlin coding style

Doesn't look Hingarish to me either, but it is potato-potato anyway. The change brings enough value to merge it as-is instead of bikeshedding for me.

@elizarov elizarov merged commit ccdc563 into master Jul 16, 2020
@elizarov elizarov deleted the foo-docs branch July 16, 2020 15:30
@elizarov elizarov mentioned this pull request Jul 16, 2020
1 task
recheej pushed a commit to recheej/kotlinx.coroutines that referenced this pull request Dec 28, 2020
The name 'foo' might be hard to get for novice developers. It is really hard to find a "meaningful" name for all examples in the docs, so this is simply a consistent solution. The alternative is to something like "simpleFlow", but adding a "Flow" suffix to the name implicitly condones Hungarian notation, which is not aligned with Kotlin coding style.
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.

None yet

3 participants