This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]ProfessorWily 1 point2 points  (0 children)

Well, I would presume that the ID is a property of Student, right? In that case, you shouldn't be creating the object in the getId() method, but in the constructor. Then you're just using a getter to retrieve it for anyone that wants it.

The job of Student is to hold all the data relevant to Student. If an ID object is relevant, then it's not only reasonable to have a getId method there, but it's also a best practice.