ara.t.howard / noaa.gov wrote:
> what's wrong with the simple solution:
>
>    class Foo
>      METHOD_DATA = {
>        'c1' => {
>          'tmp1' => ExpensiveObject.new,
>          'tmp2' => ExpensiveObject.new,
>        },
>
>        'c2' => {
>          'tmp1' => ExpensiveObject.new,
>          'tmp2' => ExpensiveObject.new,
>        },
>      }

It's certainly effective, and slightly nicer than instance variables
since it clearly describes which methods the variables go with. I'm not
wild about it just because it means that when you edit the method you
need to remember to go edit a data structure somewhere else.

(This is one reason that makes a separately-managed pool much nicer
than closure or other solutions where you must instantiate the objects
outside of the method itself.)

A viable alternative nonetheless.