Two OO ways to design something, curious what everyone's thoughts are? This is w/out context of a framework, just purely OO perspective.

Option 1 - Stateless object w/ Rich Result

Option 2 - Stateful object (e.g. command pattern + internal state to store results)

https://gist.github.com/davetron5000/19aa850df641be6c334e9b64a944b6c8

My thoughts follow, but I am not sure which is the "best" pattern - again all things being equal/not in Rails/etc.

stateful.rb

GitHub Gist: instantly share code, notes, and snippets.

Gist

@davetron5000 The answer really is “it depends” 😅

I usually always try to answer these 2 questions first:
1. What's the abstraction? What I actually try to encapsulate and simplify?
2. What would be the best API for that abstraction?

If the abstraction is just a command: do the thing -> report the result, then yeah the 1st option is better imo. But if the abstraction should actually disallow multiple calls, then this option will simply not work. That state has to be somewhere.