There are two classes:A
and B
.
And I need to implement a function whoViewed
,
I have two options,make it an member function of A
and B
.Which smells a little duplicate.
Another choice is to make it a separate class:Viewer
,but it's more abstract.
If you were me,which way will you choose?
To make it more general:
what will you do when you need to get statistic information across different classes(like get the latest viewed 10 entities{which can be A
or B
} from database) within the scope of OOP.