I need to save bookmarks for a program I am making. The bookmarks are Xposition, Yposition, and zoom. Should I just read and write all of the bookmarks to a text file, or should I put them into an Bookmarks object and Serialize it. I am interested in which one would be considered better OO design.
Share
I’d create class Bookmark anyway. Then I’d create a interface BookmarkSerializer with to methods
serialize()anddeserialize(). Then I can create my first implementation of BookmarkSerializer. It for example may be based on native java serialization, plain text, csv, xml etc. So, I can choose one, implement it and then use it in my application.When one implementation does not serve me enough I can add other. The point is that in this case I will not have to change anything in my application except initialization of the serializer itself.
I think that in your case you should start from the simplest CSV implementation and if it is not enough add as many implementations as you need.