-
Notifications
You must be signed in to change notification settings - Fork 184
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
BuiltValue deprecation #1164
Comments
Thank you for your input. In general I agree with the idea of reducing the number of competing packages. I'm well aware of the compromises made in built_value's design and so I've watched freezed with interest. I agree that freezed is better for simple use, but I think built_value is better for complex use. By that I mean, deeply nested and complex data models. It's unfortunate that we don't have one package that is equally strong on both--but nobody has come up with a way to do it yet. Perhaps simple projects should prefer freezed; but they might grow into complex projects and wish they had started with built_value. So, I don't think there is a clear recommendation to be given. The example with I also think now is not the right time to push for a single winning package on this. The Dart team is working on https://github.com/dart-lang/language/blob/master/working/macros/feature-specification.md which will mean that both built_value and freezed can be significantly improved. So, I suggest waiting for that to land then re-evaluating. BTW, another consideration is JSON serialization. I know freezed can be used with json_serializable. The comparison there to built_value is similar. For simple data models, json_serializable works. For nested models with polymorphism and generics, you will find much more success with built_value. Again, it doesn't seem like there is a way to choose definitely between them--except that if you know you will have a complex data model then perhaps you should understand the differences carefully before picking which to use. Thanks. |
We should also remember that "freezed" is not a real word and that it should be called "frozen" :D |
Just my two cents: I have experience with both This is particularly beneficial if you need to maintain complex but immutable state. For example, consider a complex BLoC state where users are stored in a Using this library makes this straightforward. Yes there is some overhead setting up built_value classes, but this extra effort is well worth it because you will be spending much more of time "modifying" these object than creating the shell classes. (And if you want to have cleaner constructors you can just create a factory method). In summary: Although the builder pattern might seem complex initially, it is actually very elegant for rebuilding complex objects. |
Thanks Felix! Always great to hear it's working as intended for someone :) I mentioned macros upthread, as it happens I have since joined the Dart language team[1] and I'm part of the group working on macros. We're in touch with the author of [1] I was already at Google and working on Dart, but on Google-internal things rather than the language team. |
BuiltValue should be deprecated, because Freezed does the same stuff and more, and much easier and more concise.
It was a good choice in 2018, but now it's undesirable for beginners to drag this outdated package into the modern projects.
BuiltValue has a strange ugly syntax with numerous getters and annotations:
While Freezed syntax is intuitive and much less verbose:
Also it's great for BLoC states declaration:
BuiltValue also has a cumbersome copying through the Builder pattern:
While Freezed supports a familiar copyWith method
You could continue supporting it, but I suggest you putting the statement "Prefer choosing Freezed" on a main page.
The text was updated successfully, but these errors were encountered: