Is there any point of making a get-method private?
Hello,Is it really a good practice to incapsulate "mob" and its getter like this if you look at the following code:
@Stateless
public class MyBean
{
@EJB
private MyOtherBean mob;
public boolean doStuff(int i)
{
getMob().doSome();
If( i < 10) { return true;}
return false;
}
private MyOtherBean getMob()
{
return mob;
}
}
I noticed this while I was writing a test for doStuff() and I needed to mock dependencis and run into a problem to mock away "mob". If the getMob() was protected "package" I easily could mock it.
What could be the reason for make the getMob() private? (Inside the get-method there is neither or nor checks like some other conditions either)
Best regards Fredrik