I have a model e.g.
Book. Besides 'natural' attributes of a book, I have some mandatory IDs I need to carry on, like
groupId. They are related to which organization unit this book belongs to.
Now, I see these two flags like something that is not part of the
Book interface. Since all the work with a book is done in the context of one organization unit. In other words, organization unit is always known for every operation out there. Yet, we need to store these data to database and have them in the model (for other modules as well).
[A] Should I put these attributes part of the
Book? Then they become mandatory flags and must be set in the constructor of the
Book. Meaning, I need to set them every time i create a book. Which somehow I don't like, as these fields belong to the organizational units, which Book should not know anything about.
[B] Should I put these attributes in some 'thread local context
? ThenBook` can not be used without the thread local, and this technical dependency is not visible from the outside.
[C] I can store them in the
Book fields, but not expose it to the
Book interface. However, when I send
Book to some other module, that module must be aware of these IDs. Should I use reflection - but then, I must be sure that fields are named the same.
So I wonder if it is possible somehow to have these fields with the
Book but not to become part of the