r/ProgrammerHumor • • Sep 23 '22

Refactoring "Just working solution ".

Post image
54.8k Upvotes

355 comments sorted by

View all comments

Show parent comments

1

u/BetterOffCamping Sep 23 '22

No, it is never the answer. This is when you look at your index of design patterns, and figure out if one of them will handle these special cases. For example, strategy pattern or chain of command pattern.

1

u/nikniuq Sep 24 '22

I find in the real world a chain of responsibility pattern is overkill for a single function that needs to cater to a vendors penchant for edge cases.

It should not be spaghetti but a bunch of clearly commented edge cases in a function is fine and often clearer than an overengineered alternative.