Skip to content

Instantly share code, notes, and snippets.

@kpgalligan
Last active August 29, 2015 14:07
Show Gist options
  • Save kpgalligan/b0950ff433708b57ca0c to your computer and use it in GitHub Desktop.
Save kpgalligan/b0950ff433708b57ca0c to your computer and use it in GitHub Desktop.
Using serializable and parcelable

In general, avoid both. We should be using EventBus where possible, and passing arguments to Fractivities by reference rather than value.

However, saving state may need a more complex object, and you may need to pass data to Fractivities that can't be done with a reference.

In almost all cases, use Serializable. Be careful to write tests that actually attempt to serialize these objects. They won't actually be serialized until they need to be, which may not work if not tested.

Parcelable is "faster", but requires lots of explicit code that can be done incorrectly. Its also easy to forget updating the state manipulation methods when updating the objects themselves.

Comparison http://www.developerphil.com/parcelable-vs-serializable/

@kpgalligan
Copy link
Author

Testing comments

@kpgalligan
Copy link
Author

More tests

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