I need to make a decision to keep only identifier of another class or an object reference to it within another class. The situation is as follows:
public class Article {
private int ownerId;
}
or:
public class Article {
private User owner;
}
And here comes the problem:
- I have separated my domain classes into another module (say
domain, and the rest of the project is incore), this is because thisdomainmodule can be imported by some users (Drools Workbench users who design processes) - The
Articleclass is in thedomainmodule. domainmodule is not dependent on Spring security, but thecoreis.- If I will use an object reference in
ArticleI will have to include Spring Security as a Maven dependency todomainmodule (becauseprivate User owneris a Spring SecurityUser), which will make it significantly greater in size. - I don't quite want my
domainmodule to be a big jar file, because it makes it hard to include in Drools, or even more around within company.
So, what might be the correct way to go in this situation? Normally, I would go for the object reference for the obvious reasons that can be found here as well, but I am inclined to make an exception for this case.