nus-cs2103-AY2223S2 / forum

12 stars 0 forks source link

Must you always categorise classes with similar functionality/ behaviour together? #286

Closed ChickenChiang closed 1 year ago

ChickenChiang commented 1 year ago

For our tP we are adding a Team, UniqueTeamList, and TeamTag class to the addressbook. Their behaviour is similar to that of the pre-existing Person, UniquePersonList, and Tag classes.

Just because they behave similarly do we have to make it such that they both extend the same parent class/ implement the same interface?

Does this violate any coding standards, or is it sufficient to mention that they behave similarly in the DeveloperGuide and in the comments? I can't seem to find any coding priciples that it would violate in the textbook. My thinking is that it is not necessary as they are divided into their respective packages i.e. team package and person package.

Thanks in advance!

damithc commented 1 year ago

Good question for a OOP discussion @ChickenChiang Views from others welcome

damithc commented 1 year ago

Does this violate any coding standards

Not according to https://se-education.org/guides/conventions/java/intermediate.html

My thinking is that it is not necessary as they are divided into their respective packages i.e. team package and person package.

Yes, you can go with this approach first and monitor the situation. If it makes the code harder to understand/maintain, you can try other alternatives, of which inheritance is one.