Why do cascading BaseOperation extend serializable?

91 views Asked by At

I want to implement a function that extends BaseOperations and i get an exception if my class has a member that is not serializable. Why must the function be serializable? is it ok to use java transient with that member? is it ok to use static members in my funcion?

1

There are 1 answers

0
lambad On

When posting a question like this, do share your code and error in a precise way.

When you declare a variable as transient then the variable is not eligible to be persistent. So you cannot serialize it. Static fields are not used to represent the state of an object. Static fields represent class state. If you really want to serialize then may be you will have to develop your own serializer/deserializer.

If a class have variable and methods that holds and modifies state then it is good to serialize it. If a variable values changes then it means its state is changing. Also note that the BaseOperation class is an abstract class so any other class that make BaseOperation as its parent class will automatically have serialization.