Which is the better approach
public class Account
{
public UserAccount GetUserDetails(string acctId)
{
return new UserAccount().GetDetails(); //call method from class UserAccount
}
public UserAccount GetUserDetails(string acctId)
{
return new UserOtherDetails().GetDetails(); //call method from another class
}
}
or contain the class like this
public class Account
{
private UserAccount userAccount; //contain UserAccount class
private UserOtherDetails userOtherDetails;
public UserAccount GetUserDetails(string acctId)
{
return userAccount.GetDetails(); //invoke the method from UserAccount class
}
public UserOtherDetails GetOtherDetails(string acctId)
{
return new userOtherDetails().GetDetails(); //call method from another class
}
}
or any other approach guys?
EDIT: what if I Add parameters on the method?
Additional: My point here is I don't want to instantiate UserOtherDetails class when I'm calling the GetUserDetails Method