Say I have a long-established repository:
interface IDonutRepository { public IEnumerable<Donut> GetDonuts(); }
That was a long time ago, and the GetDonuts method does what it says. Then one day I need to add a new screen that shows all the donuts in the database, and it turns out that the method has a hidden function - it filters out all the donuts, where stale = true . But on my new screen I want to show them all, even outdated ones! What is the best approach here?
Assuming this method is ubiquitous and the default behavior should remain the same, is it best to add a new method called GetAllDonuts that does not filter, or should I just add onlyFresh to the GetDonuts method?
I suppose this is fair, but I wonder if there are more reasonable answers there?
source share