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 thisdomain
module can be imported by some users (Drools Workbench users who design processes) - The
Article
class is in thedomain
module. domain
module is not dependent on Spring security, but thecore
is.- If I will use an object reference in
Article
I will have to include Spring Security as a Maven dependency todomain
module (becauseprivate User owner
is a Spring SecurityUser
), which will make it significantly greater in size. - I don't quite want my
domain
module 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.