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
Pick up properties from implemented interfaces #22
Comments
No, it's not planned; the answer is as for @autovalue, which is that there Effective Java goes into some detail, here's an excerpt: "It turns out that However, it is possible to implement interfaces, and this is the right I believe it should also work to use mixins to share implementation, Do you have any use cases in mind that aren't covered by interfaces+mixins? On Sat, 23 Apr 2016 at 02:34 Andersmholmgren notifications@github.com
|
I meant more that the code generator does not pick up inherited properties from implemented parent classes. If you look at https://github.com/Andersmholmgren/vcore/blob/master/lib/src/model/model.dart#L102 Similarly for the builders https://github.com/Andersmholmgren/vcore/blob/master/lib/src/model/model.dart#L118 Other than that it seems to be working for my current use case which is (this project) where I am building a meta model for If I get as far as implementing XMI support and mapping ecore to vcore, then in theory we should be able to design our domain models as class diagrams, using eclipse ecore tools then generate BuiltValues + their Builders. |
Forgot to mention a more serious problem. I was forced to create a custom serialiser (https://github.com/Andersmholmgren/vcore/blob/master/lib/src/model/model.dart#L118) because I have properties using a base type.
Properties like
|
Good stuff. Let's see, quite a few threads now... One quick question, why do you define "build" factories, e.g. "factory Property.build"? It should be as nice to use the builder. If you have to define your own factories, the builder isn't doing its job! Also, it would be a bit neater to use the constructor instead of the builder, so instead of:
You could do
Re: not picking up inherited properties from implemented interfaces, yeah, that should be added. Good point. Could you rename this issue to something more specific for that please? "Pick up properties from implemented interfaces" maybe? Then we can add separate issues for anything else. Object modelling with built_value is a great idea, that's exactly the sort of thing it's intended for. (Although we never went so formal.) Re: serializers, yes, this is a planned feature, just not implemented yet. Could you please file an issue over at https://github.com/google/built_json.dart/issues -- something like, "allow non-concrete serialized types provided all implementations are serializable"? Thanks for all the input! I won't get to work on these this week because I'm on vacation, but hopefully will get to them the week after. |
Actually the However, I had missed that I could use the Years ago when I was an architect at an investment bank I got quite into EMF and ecore. We had truly massive domain models (based on the FpML standard) and needed to transform to different related domain models (sometimes bidirectionally). One of the things that I really liked about EMF is that it gave a real uniformity to certain APIs. You essentially just needed to understand a domain model (e.g. XML Schema). The way you interacted with that model was the same as with any other domain model (FpML, JSON Schema etc). I'm not sure how far I'll take this but am keen to regain some of the bits I liked from that experience. I'll rename the issue and create a new one as you suggested |
Great -- that's how it's intended to be used. Of course, any suggestions, let me know. I'll try to take a look at these two issues in the next couple of weeks, they should be relatively straightforward. Thanks. |
I had a look into this. It's straightforward for value types; just count getters from implemented interfaces as properties. For builders there are a few more cases because of the facility to set a default. If you don't want a default then the generated builder class should have a concrete field. If you do want a default, you need to write the concrete field yourself. This is doable, but I think I should tidy up the generation code first, adding a data model rather than doing everything "procedurally". That will make this change easier, and hopefully easier to get right! |
makes sense. I think it's worth investing in doing it properly |
Unless I'm missing something you can't currently have a hierarchical model, where you inherit properties from parent models and similarly builders inherit from other builders.
Is this planned?
The text was updated successfully, but these errors were encountered: