DEV Community

Discussion on: I'm Sandi Metz, Ask Me Anything! [Finished]

Collapse
 
jmike1690 profile image
Miguel

Hi Sandi, thanks for doing this AMA!

I had a situation where a route call a method to get an amount, and this method used a switch for check the type (Each case call a method).

I'm using Laravel with the pattern of repository/interface so I created 2 repositories (I notice that some cases of the switch are similars so I decided to integrate them in the repositories).

First I create an array of the repositories

Array of repos

Then in the method amount I change to this

Array of repos

What do you think? (I take base of this article of you when-code-duplication-is-the-right...