Skip to content
This repository has been archived by the owner on Dec 3, 2019. It is now read-only.

Ohana should vend immutable models #23

Open
adam-zethraeus opened this issue Sep 5, 2016 · 3 comments
Open

Ohana should vend immutable models #23

adam-zethraeus opened this issue Sep 5, 2016 · 3 comments

Comments

@adam-zethraeus
Copy link
Contributor

For discussion:
The OHContact has mutable fields. Whilst customProperties and tags should perhaps stay mutable for the attachment of display metadata, the rest of the fields should probably be immutable when vended by the framework

@NickEntin
Copy link
Contributor

I agree there are definite advantages to OHContact having immutable fields, but there are some problems associated with this. Of course, the data providers, post processors, and selection filters need to modify OHContact models, so we would presumably need to create an OHMutableContact model and use that when passing through components. Then when you access dataSource.contacts we would return immutable copies, but that creates a problem when you try to compare contacts and selectedContacts when you keep making copies. Additionally, apps may want to modify the contacts, and then save them (via the CN identifier, persisted contacts, etc.). We could make a mutable copy method for this, but then the contacts in the data source can't be updated, so you would have to reload everything. Overall, I think the disadvantages outweigh the advantages. Are there any specific advantages that you think make it worth it?

@maxwellE
Copy link
Contributor

maxwellE commented Mar 2, 2017

Solved in #42

@maxwellE maxwellE closed this as completed Mar 2, 2017
@adam-zethraeus
Copy link
Contributor Author

This is orthogonal to any particular copy bug.

A decent brief outline: https://engineering.linkedin.com/blog/2016/04/keeping-immutable-models-consistent

@adam-zethraeus adam-zethraeus reopened this Mar 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants