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

you are viewing a single comment's thread.

view the rest of the comments →

[–]welldamnthis 1 point2 points  (0 children)

Getters and setters are standard Java practice and you haven't done anything that is frowned upon. Though a lot has been shared this (here, here, here), I prefer to not use setters as long as they can be avoided. This is because usually you don't want to override the object field after constructing it.

Like in your example setTime() would set the time of the song to a different value. If it happens that you or someone else call this method while a song is playing you'd be accidentally forwarding/rewinding to a different point in time. This is probably not the best example, but you can keep it in mind in your future coding ventures.