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 Nothing type to avoid confusion with Kotlin's #1335

Closed
alexander-yevsyukov opened this issue Nov 27, 2020 · 7 comments
Closed

Rename Nothing type to avoid confusion with Kotlin's #1335

alexander-yevsyukov opened this issue Nov 27, 2020 · 7 comments
Milestone

Comments

@alexander-yevsyukov
Copy link
Contributor

alexander-yevsyukov commented Nov 27, 2020

Kotlin has standard type which is named Nothing. It is used in function declarations when it never returns because of throwing an exception.

We have a specialized Message type, io.spine.server.model.Nothing, which serves as a return type of handler methods that do not return anything. These methods do return an instance of such message and exit normally.

This may bring various confusions for Kotlin people:

  • Why do we have a handler method that never completes? Just by looking at the method signature, it's not possible to tell that it's Spine-specific Nothing, not the standard Kotlin's one.
  • What doesn't this handler work? I don't know what declaring wrong Nothing in a Kotlin code for a handler would cause, but I'm not sure it would be OK.
  • Fully-qualified Spine's Nothing when the user's code needs to use Kotlin's one.
  • etc.

In order to avoid this confusion we need to have a type with another name.

@alexander-yevsyukov
Copy link
Contributor Author

To be mentioned as breaking change in Release Notes.

@alexander-yevsyukov
Copy link
Contributor Author

Suggested alternative name: None.

@alexander-yevsyukov alexander-yevsyukov moved this to 📋 Backlog in v2.0 Sep 22, 2022
@alexander-yevsyukov alexander-yevsyukov added this to the M1 milestone Oct 30, 2022
@alexander-yevsyukov
Copy link
Contributor Author

Previously suggested empty Tuple type won't work because our Nothing is frequently used in tules like this: EitherOf2<JobComplete, Nothing>.

@alexander-yevsyukov
Copy link
Contributor Author

We currently have two typealias-es called NothingHappened and NoReaction. This should ease the name clash with the standard Kotlin type.

See the io.spine.server.model.EventExts.kt file for details.

@armiol
Copy link
Contributor

armiol commented Apr 16, 2024

@alexander-yevsyukov
We can only return Nothing in reaction to some event, which we may or may not want to react upon.
It is impossible to return Nothing from a command handler for obvious reasons.

NoReaction reflects what we want to say perfectly:

"Something has happened, and we could potentially react on it. But at this time, we chose not to."

Using NothingHappened is misleading, because it sounds like an event. But as stated earlier, some event has happened—we just don't want to react.

Therefore, I'd stick to NoReaction as a typealias. And I would drop NothingHappened.

@alexander-yevsyukov
Copy link
Contributor Author

Therefore, I'd stick to NoReaction as a typealias. And I would drop NothingHappened.

Yeah, see this commit.

@alexander-yevsyukov
Copy link
Contributor Author

Resolved by #1554.

@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in v2.0 Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

No branches or pull requests

2 participants