3

In my Java application, I store some data in serveral files in a proprietary format. At runtime, the content and some metadata are stored in an object. In my current approach, the class looks like this:

all data stored in the object

An other approach would be to encapsulate metadata and content in their own objects:

enter image description here

What are the advantages / disadvantages of these approaches? Which one would you suggest me to use?

Thanks!

Edit

The metadata and the content are stored in different files which I load lazily. So the metadata or content of the object is not available if it´s not requested. There is no special behaviour in the object. Just getter and setter.

Franz Deschler
  • 2,456
  • 5
  • 25
  • 39

1 Answers1

1

It's hard to tell without a concrete example.

Anyway, you should try not to violate single responsibility principle, hence better way probably is to split that class into two.

Single responsibility principle says that there should be only one reason to change.

Yet I would say that meta data is not really an object, just a data structure. Does it have any behaviors?

Provide some real world example so we can answer your question more precisely.

Rafał Łużyński
  • 7,083
  • 5
  • 26
  • 38