Transparently storing class state without exposing implementation
Posted
by RoToRa
on Stack Overflow
See other posts from Stack Overflow
or by RoToRa
Published on 2010-05-06T09:52:55Z
Indexed on
2010/05/06
9:58 UTC
Read the original article
Hit count: 171
I have a model (MVC) class whose internal state (which basically contains of private int
fields) I want to store.
The program is running on Android (for now) so I need to store the in a Bundle
, but I'll be using the same class later in a desktop application where I'll have to store the state some other way, so I can't reference Bundle
directly in my class.
So my question is: What is the best way to store (and retrieve) the state of a class without exposing it's implementation?
The best I could think of removing the private
access modifier so that the fields become package accessible and create read/write helper classes in the same package, but that somehow seems wrong.
© Stack Overflow or respective owner