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

Immutable types #11

Draft
wants to merge 28 commits into
base: master
Choose a base branch
from
Draft

Immutable types #11

wants to merge 28 commits into from

Conversation

dmdashenkov
Copy link
Contributor

@dmdashenkov dmdashenkov commented Sep 4, 2020

In this PR we introduce immutable Dart types generated based on Protobuf definitions.

Standard Protobuf Dart tool generated code which is always mutable. Even though messages can be "frozen", their API always has setters. This is confusing so we want to make all Protobuf messages immutable by default.\

The current idea of going about this problem is to generate abstract classes based on Protobuf definitions and then feed those classes to built_value — a builder which would complete the boilerplate side of code generation, such as builders, null checks, etc.

@dmdashenkov dmdashenkov self-assigned this Sep 4, 2020
@alexander-yevsyukov
Copy link
Collaborator

@dmdashenkov, have a look at https://pub.dev/packages/freezed. Their approach does not require calling a method. They construct things already immutable.

@dmdashenkov
Copy link
Contributor Author

Suspended for now. Please do not delete the branch.

@alexander-yevsyukov
Copy link
Collaborator

@dmdashenkov, I'm reopening the PR to:

  1. prevent accidental deletion of the associated branch;
  2. make the fact that we've got work in progress and ongoing communications with Google visible to the rest of the team and people getting familiar with the framework.

Please also mention the issue you created in this PR, so that people can find it from that issue and see why our request is important.

@alexander-yevsyukov
Copy link
Collaborator

@dmdashenkov, please also describe this PR so that people can quickly grasp what it's all about.

@alexander-yevsyukov
Copy link
Collaborator

@dmdashenkov, what you've had in meeting minutes with @armiol should go into this PR.

@dmdashenkov
Copy link
Contributor Author

While developing this feature, we've faced a couple of problems.

  1. Standard Protobuf Dart API provides no common interface for each message which we would be able to leverage. This means that there's no way to maintain the structure of the message or to use polymorphism in our client API.
  2. Standard messages have to be retained in public access scope, since we want to use them for serialization purposes. If we hide the messages into a file-private scope, they become unavailable for other messages to be used as field types, which is unacceptable. We're left with 2 sets of classes: mutable and immutable, which are separates in names with a class name prefix.

@dmdashenkov
Copy link
Contributor Author

Right now, we're trying to find out if the Dart team could help us with this problem. Please see the issue.

@dmdashenkov dmdashenkov removed their assignment Sep 22, 2023
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