-
Notifications
You must be signed in to change notification settings - Fork 103
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
Serial vs Parcelable #27
Comments
I have the same question, why not use Parcelable to solve your serialized problem? |
Parcel/Parcelable is not meant to be used for serialization on a persistent storage (check the Parcel javadoc). Try to update the structure of a Parcelable object, then parse the content of old ones.. it will not work, and it will be impossible to debug. They are designed for inter-process communication first. |
Thank etibaldi, if u want to persist some binary data on storage. Serial is a better choice. |
Thanks for your answer, @etibaldi. Here are some aspects in which Serial differs from Parcelable:
@afauci goes into some detail in her post: https://blog.twitter.com/engineering/en_us/topics/open-source/2017/introducing-serial.html. Ali, what do you think about adding this comparison at the bottom of the readme file? |
Sure, let me add some comparisons in the documentation, I'll put up a diff
for that this week.
…On Thu, Nov 23, 2017 at 11:56 AM, César Puerta ***@***.***> wrote:
Thanks for your answer, @etibaldi <https://github.com/etibaldi>. Here are
some aspects in which Serial differs from Parcelable:
- As mentioned above, Serial is meant for persistent storage, while
Parcelable is not, since its binary format is not guaranteed to be stable
across versions of Android. Applications end up implementing both
Parcelable and other serialization protocols in their model objects.
- Serial has powerful support for debugging, which is critical for
persistent storage. Serial detects issues in the input stream as soon as it
comes across a field with the wrong type, and throws an exception
describing the structure of the object, the mismatched field and the
expected field type. In contract, the behavior of Parcelable with invalid
input is undefined - it typically crashes the application, but it may just
return invalid data.
- Serial adds minimal metadata to the output stream to support
backwards compatibility, either through version numbers in all objects or
peek of the next field in the stream. Parcelable does not include any extra
metadata or support for changes.
- Parcelable requires implementing the Parcelable interface, which is
only possible in objects you own. Also, it forces you to couple your model
objects with specific serialization schemes, while serializers can be
defined separately.
- Last time I checked, Serial is faster than Parcelable in Lollipop
and above, since Art precompiles dex files, while Parcelable requires
frequent context switching through JNI into the native layer.
@afauci <https://github.com/afauci> goes into some detail in her post:
https://blog.twitter.com/engineering/en_us/topics/open-
source/2017/introducing-serial.html.
Ali, what do you think about adding this comparison at the bottom of the
readme file?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#27 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ACUcPIyUv_06ije7uFFB-O74VTkxWN7fks5s5c3ygaJpZM4Qm_EV>
.
--
Ali Fauci
*(202)251-3998*
|
I didn't see
Parcelable
mentioned anywhere in your blog post. How is this different/better than Android's Parcelable?The text was updated successfully, but these errors were encountered: