Skip to content
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

Serialization inaccurate #22

Closed
consp1racy opened this issue Jul 18, 2017 · 1 comment
Closed

Serialization inaccurate #22

consp1racy opened this issue Jul 18, 2017 · 1 comment

Comments

@consp1racy
Copy link

What is serialization? How do you implement it?

Serialization is the process of converting an object into a stream of bytes in order to store an object into memory so that it can be recreated at a later time while still keeping the objects original state and data. In Java there are two methods of doing this, one is by implementing Serializable or Parcelable.

Parcelable is Android exclusive. Java has Externalizable.

In Android, however, Serializable should never be used in Android.

That's like saying you should never use enums on Android. (You shouldn't use enums to represent an integer or string constant.)

Parcelable was created to be more efficient then Serializable, and performs about 10x faster then Serializable because Serializable uses reflection which is a slow process and tends to create a lot of temporary objects which may cause garbage collection to occur more often.

That's the default if you just stamp Serializable interface onto a class and don't override writeObject or don't implement Externalizable. There's no mention that Parcelable is not as automatic as Serializable.

@amitshekhariitbhu
Copy link
Owner

will update it accordingly.

JosiasSena added a commit to JosiasSena/android-interview-questions that referenced this issue Jul 25, 2017
Added code sample for Parcelable and Serializable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants