I have an ID field in the database which is a primary key. Is it a good practice to define it in the class? I will need the key to perform updates and other operations.
I have this doubt because I’m not sure, but a professor said that it is not a good practice.
EDIT:
public class Pagina {
private int id; //<--this is an good practice?
private String urlOriginal;
private String urlRedirected;
private String content;
private Link[] links;
private Date updateDate;
private Date visitDate;
private boolean visitedLinks;
}
According to my professor, in the UML solution of the problem, the Id should not be defined because each object is unique and don’t needs an identifier attribute to this, but after, depending on which technology used, in the final project, the Id is necessary and there are no problems in using it. This not violate the good practices.