Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • "Would there ever be a reason to have a method that takes a Person, but doesn't know if it's a Student or a Teacher?" - Sure: the Person's name changes. "how do you know if the classes are really related in your domain?" - Okay, and if we determine that they really are related, what then? Commented Feb 18, 2022 at 15:56
  • @8bittree If they really are, then I think it's okay for them to have a common base class. But if they aren't, and the person's name changes, you can just change it on the Student, or on the Teacher, as appropriate. Commented Feb 18, 2022 at 18:59
  • So, embrace the very painful problems of a common base class, and/or enjoy de-synchronization issues? Commented Feb 18, 2022 at 19:43
  • @8bittree As I said, I don't think there actually are any very painful problems, just a class that isn't pulling its weight, and obviously it is a matter of opinion whether it is pulling its weight. As for the synchronization issues, if the roles are treated as distinct, it wouldn't be an issue. Commented Feb 18, 2022 at 20:15
  • "As for the synchronization issues, if the roles are treated as distinct, it wouldn't be an issue." Bob the Student and Teacher fills out and submits the paperwork to change his address. A week later he's received his report card and is wondering where his paycheck is because his address was updated in his Student object, but not in his Teacher object, resulting in his paycheck going to his old address. Also, he keeps getting double notifications every time the school closes for bad weather, because his phone number is in both objects. Commented Feb 18, 2022 at 21:28