What is Serializable and Parcelable?

  • Thread starter Thread starter Ashish Bisht
  • Start date Start date
Click For Summary

Discussion Overview

The discussion centers around the comparison between Serializable and Parcelable in the context of Android development. Participants explore the advantages and disadvantages of each approach, considering performance and code complexity.

Discussion Character

  • Technical explanation
  • Debate/contested

Main Points Raised

  • One participant notes that Serializable is a marker interface that can be implemented on a class and its children, but it is slower and creates many temporary objects.
  • Another participant argues that Parcelable is a more specialized interface that is significantly faster than Serializable, though it requires more boilerplate code to implement.
  • It is suggested that the choice between Serializable and Parcelable should be made on a case-by-case basis, weighing the extra time required for Parcelable against the potential slowness of Serializable, which may not be noticeable in many cases.
  • A participant encourages looking up Android documentation for a comprehensive understanding of both options.

Areas of Agreement / Disagreement

Participants express differing views on the practicality and performance implications of using Serializable versus Parcelable, indicating that no consensus has been reached on which approach is definitively better.

Contextual Notes

The discussion does not resolve the trade-offs between the two approaches, and assumptions regarding performance impact and code complexity remain unexamined.

Ashish Bisht
Messages
2
Reaction score
0
Hi everyone, i am an Android developer and want to know your views on Serializable and Parcelable. Which is best approach in Android that will be helpful for me ?
 
Technology news on Phys.org
Serializable is a marker interface, that you implement on a class and its children. The downside of this approach is that it's slow and creates a lot of temporary objects.

Parcelable is a more specialized interface, which is significantly faster than Serializable. The downside is that you have to write some - enough in many cases, boilerplate code.

Everything has its cost. If you can afford the time , then it's better to use Parcelable. On the other hand, in most cases the slowness of Serializable - that is due to reflection that is used, won't be particularly noticeable, so you can write significantly less code and be OK. In general, you have to judge yourself on a per case basis, if it worths the extra time or not.

I strongly recommend to look up Android documentation, in order to have a complete view about the two choices.
 
Last edited:
  • Like
Likes   Reactions: harborsparrow and Ashish Bisht
Hello Ashish, :welcome:

+1 for QQ. But I wonder why -- as an android aficionado -- you didn't simply google 'serializable vs parcelable' and ended up with D Phil ?
 
  • Like
Likes   Reactions: Ashish Bisht
Thank you everyone for valuable suggestion.
 

Similar threads

Replies
10
Views
7K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 9 ·
Replies
9
Views
3K
Replies
11
Views
3K
  • · Replies 17 ·
Replies
17
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
Replies
3
Views
1K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 10 ·
Replies
10
Views
2K