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

Retrieve model from differents keypart (but same content) #88

Closed
agonist opened this Issue Dec 2, 2013 · 7 comments

Comments

Projects
None yet
2 participants
@agonist
Contributor

agonist commented Dec 2, 2013

Hi,

I want to retrieve different model instance with different keypart like that :

 MyModel model1 = JRebirthThread.getThread().getFacade().getUiFacade().retrieve(MyModel.class, new SimpleListProperty<String>());

and

 MyModel model2 = JRebirthThread.getThread().getFacade().getUiFacade().retrieve(MyModel.class, new SimpleListProperty<String>());

But when I do that I get always the same model instance cause JRebirth use a toString() to compare if a model already exist

I will obtain with my example something like that in the method hashCode from MultitonKey.class

com.toto.list.MyModelListProperty [value: []]1944695710|

and

com.toto.list.MyModelListProperty [value: []]1944695710|

So JRebirth think this is the same instance but it's not.
It will be better if Jrebirth use the instance to check if the model already exist.

Thank's

@sbordes

This comment has been minimized.

Show comment
Hide comment
@sbordes

sbordes Dec 2, 2013

Member

Hi Bastien,

Currently, the aim of key parts object are to be an unique combination of object that will be merged with toString method to generate a unique hash code.

I understand that you use SimpleListProperty to handle the data you are binding into your model-view.

So why don't you use a JavaBean (with all javafx properties you want) that will return an unique string (managed by toString method) easy to read when viewed into a debugger and fast enough when managing hundred of instances ?

I have planned to let the option to generate a custom key per Component (Model, Command & Service), I will perform this change soon

Let me know if you have any thought

Member

sbordes commented Dec 2, 2013

Hi Bastien,

Currently, the aim of key parts object are to be an unique combination of object that will be merged with toString method to generate a unique hash code.

I understand that you use SimpleListProperty to handle the data you are binding into your model-view.

So why don't you use a JavaBean (with all javafx properties you want) that will return an unique string (managed by toString method) easy to read when viewed into a debugger and fast enough when managing hundred of instances ?

I have planned to let the option to generate a custom key per Component (Model, Command & Service), I will perform this change soon

Let me know if you have any thought

@ghost ghost assigned sbordes Dec 2, 2013

@agonist

This comment has been minimized.

Show comment
Hide comment
@agonist

agonist Dec 3, 2013

Contributor

Using a Java Bean for a single property is a bit confusing.

It's not really logical that if I have two property with the same content, JRebirh return the same model instance, and if I have different content,JRebirth return different instance of the model.
This means that my unique key may change according to the content of my ListProperty, which is not why I (and maybe other developers too) expect

Contributor

agonist commented Dec 3, 2013

Using a Java Bean for a single property is a bit confusing.

It's not really logical that if I have two property with the same content, JRebirh return the same model instance, and if I have different content,JRebirth return different instance of the model.
This means that my unique key may change according to the content of my ListProperty, which is not why I (and maybe other developers too) expect

@sbordes

This comment has been minimized.

Show comment
Hide comment
@sbordes

sbordes Dec 3, 2013

Member

I have added some confusion when I merged 2 concepts:

  • Model Object
  • Component Key Part

The Model Object is the JavaBean or the business object (could be a string) that will be rendered by the model.

The Key part is a set ob object that shall guarantee the uniqueness of the model.

Most of times these 2 concepts are equals:
ie when designing a model that will display information about a person, the PersonModel will have a model object equals to a Person JavaBean and the Person object will return a unique key (name+firstname+birthdate+anysaltyouneed)

But if you are designing a bubble animation with some BubbleModel, your model object could be only a Color (red, blue etc...) but your key part must add a value that guarantee uniqueness of the model (like a incremental integer)

So to let your key part unique you must something that guarantee uniqueness if you can have ionto your application 2 model with same model object.

Is it a bit more intelligible ?

Member

sbordes commented Dec 3, 2013

I have added some confusion when I merged 2 concepts:

  • Model Object
  • Component Key Part

The Model Object is the JavaBean or the business object (could be a string) that will be rendered by the model.

The Key part is a set ob object that shall guarantee the uniqueness of the model.

Most of times these 2 concepts are equals:
ie when designing a model that will display information about a person, the PersonModel will have a model object equals to a Person JavaBean and the Person object will return a unique key (name+firstname+birthdate+anysaltyouneed)

But if you are designing a bubble animation with some BubbleModel, your model object could be only a Color (red, blue etc...) but your key part must add a value that guarantee uniqueness of the model (like a incremental integer)

So to let your key part unique you must something that guarantee uniqueness if you can have ionto your application 2 model with same model object.

Is it a bit more intelligible ?

@agonist

This comment has been minimized.

Show comment
Hide comment
@agonist

agonist Dec 3, 2013

Contributor

it's more clear like that yes. So I just add a keyPart corresponding to a bean and now it's work fine. So than's for you explaination about that :)

Contributor

agonist commented Dec 3, 2013

it's more clear like that yes. So I just add a keyPart corresponding to a bean and now it's work fine. So than's for you explaination about that :)

@agonist agonist closed this Dec 3, 2013

@sbordes sbordes reopened this Dec 3, 2013

@sbordes

This comment has been minimized.

Show comment
Hide comment
@sbordes

sbordes Dec 3, 2013

Member

I reopen it to fix the FIX ME tag into the code.

The goal is to provide a way to generate the custom unique key directly from the component (ie: getComponentKey)

Member

sbordes commented Dec 3, 2013

I reopen it to fix the FIX ME tag into the code.

The goal is to provide a way to generate the custom unique key directly from the component (ie: getComponentKey)

@sbordes

This comment has been minimized.

Show comment
Hide comment
@sbordes

sbordes Dec 6, 2013

Member

To let the option to generate the key by using another method, an annotation can be used on top of KeyPart class or internal methods.

It allows to call one or several method to generate the unique key.

Then all key parts will be concatenated and transformed as a hash

Member

sbordes commented Dec 6, 2013

To let the option to generate the key by using another method, an annotation can be used on top of KeyPart class or internal methods.

It allows to call one or several method to generate the unique key.

Then all key parts will be concatenated and transformed as a hash

@sbordes

This comment has been minimized.

Show comment
Hide comment
@sbordes

sbordes Dec 9, 2013

Member

A new annotation was introduced by commit : 3b91e33

It allows to define custom method used to generate the String unique key for any key part.

Member

sbordes commented Dec 9, 2013

A new annotation was introduced by commit : 3b91e33

It allows to define custom method used to generate the String unique key for any key part.

@sbordes sbordes closed this Dec 9, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment