4 ms·
To add to this, a pattern that's really helpful here is: findThingWeShouldDoThisTo can both satisfy a condition and greatly simplify doThis if you can pass it t
by btown 1y ago
To add to this, a pattern that's really helpful here is: findThingWeShouldDoThisTo can both satisfy a condition and greatly simplify doThis if you can pass it the thing in question. It's read-only, testable, and readable. Highly recommend.
- efitz 1y agoThis is not obvious to me. The whole point was to separate the conditionals from the actions. In your example, it’s not clear if/how much “should we do this” logic is in your function. If none, then great; you’ve implemented a find or lookup function and I agree those can be helpful. If there’s some logic, eg you have to iterate through a set or query a database to find all the things that meet the criteria for “should do this”, then that’s different than what the original commenter was saying. maybe: doThis( findAllMatchingThings( determineCriteriaForThingsToDoThisTo())) would be a good separation of concerns
- hinkley 1y agolet list = findHumansToKill(); //list = []; killHumans(list);
- deleted 1y ago[deleted]