Given the classes:
public class SocialNetwork
{
private final Map<String, User> users;
...
}
public class User
{
private final String user;
private final LinkedList<String> followers; //stores the users that "user" follows
...
}
I was wondering if it is considered a good design practice (and why) to store the user's name in "followers" (username is unique and can't be changed) and retrieve the reference to the object through the "users" hashmap - as in the example above - or to store the object of the "User" class directly in "followers" - as in the example below?
//EDIT: I modified this example to make it less ambiguous
public class SocialNetwork
{
private final Map<String, User> users;
...
}
public class User
{
private final String user;
private final LinkedList<User> followers; //stores the users that "user" follows
...
}