I have some general questions regarding interface usage:
- What is the advantages in creating interface for each object class ?
- Should interface only contains 'getter' methods?
- Why not also the setter?
- Why should I create for each object class an interface? Will it served me in the JUnit tests?
For example :
public interface Animal {
public getVoice();
public String getName();
}
public class Dog implements Animal {
private String name;
public getVoice(){
System.out.println("Brrr");
}
public String getName(){
return this.name;
}
public void setName(String name){
this.name = name;
}
}
Thanks