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

An “issue” with the second one in this example is that the interface becomes “temporal” — you *always* have to call `do_it` before you can access the results.

In these cases I prefer te return some result object. It juist suits the single-purposeness of this type of service/command object better.

That being said… I use ActiveRecord everyday and it has that same temporal interface.

It feels like less of a problem there.. Entities/Records aren’t stateless. Commands should be?