Classes Implementing Serializable

When we develop a class in java, the decision about whether to make the class serializable or not is usually simple. If the class represents a model object that can be passed through n / w, it must be serializable.
Is this reasoning correct?
If so, what is the logic behind some of the Java API classes that can be serializable and others not?
From this list of native classes that implement Serilizable, it seems that there are several reasons for implementing serializable ones.
http://download.oracle.com/javase/6/docs/api/java/io/class-use/Serializable.html

Any clarification would be appreciated.

+3
source share
2 answers

If the class represents a model object that can be passed through n / w, it must be serializable. Is this reasoning correct?

This reasoning is somewhat correct. If you are creating a public API where compatibility is important, you might want to serialize classes that might need to be serialized one day. However, if you are creating a private application, classes should only be serialized when necessary. One of the reasons (among several) to try to avoid implementation Serializableis that it introduces the need to maintain and protect the newly added "interface" to your serializable class: its representation in byte code.

, Java Java API , ? Serilizable, , .

, Java API Serializable, , - , , Serializable, Serializable, , java.lang.Object Serializable, java , . : -.

0

, Serializable, .

. , , Java. , , ( ).

. / ( , ).

Serialzable , ... , . .

0

Source: https://habr.com/ru/post/1781191/


All Articles