Today I want to share a fun refactor that finally "clicked" for me (and it was right there in plain view for quite some time!). Let me set the stage.
>I had a fairly productive refactoring session on a small function that I thought I would write about. In Galley, my recipe/cooking application, I have a home / index page where users can search and view recipes. At the current state, a user can search by recipe name and can filter by all recipes or their recipes. At the moment I am building out a tagging functionality such that a user can search by tags shared between recipes such as spicy, salad, or easy, for example.
With these three sources of permutation, I need to account for a database query that could have a mixed bag of search queries, tags, and filters.
>