[Borges-users] StateHolder II
Eric Hodel
drbrain at segment7.net
Sun May 2 22:44:12 EDT 2004
??????? ???????? (slepnev_v at rambler.ru) wrote:
> >Which would return an object wrapped in a StateHolder?
>
> Yeah. And move the register_for_backtracking from StateHolder's
> constructor into Session#state_holder. Users should use this instead
> of creating a new instance. StateHolder will only consist of
> attr_accessor :contents.
>
> Rationale: session.state_holder(contents) is shorter than
> Borges::StateHolder.new(contents), and the association with a session
> is explicit (not magical for the app developer). Also,
> Session#register_for_backtracking and Session#state_holder pair up
> nicely: one backtracks the instance variables, the other backtracks
> the value of the object reference.
I'm not sure I like that, it feels odd that session is both a factory
for StateHolders in addition to its other duties.
Even though Session and StateHolder are tightly coupled, it seems
unnatural to have to ask Session for a StateHolder. Also, if the
call to register_for_backtracking is removed from StateHolder, it
behaves like a handle when created with new, and as a StateHolder when
created by Session.
I don't feel its a net gain to change things from the way they are.
> Also, one dependency less on the :current_session hack.
I don't think there is any less hackish way to accomplish this :(
> Also it will be easier to add a StateHolder to a Session from outside
> it (if someone would ever need that =)
Ya Ain't Gonna Need It (YAGNI) :)
Keeping state is one of Session's primary responsibilities, so its hard
to see where you can divorce the two.
--
Eric Hodel - drbrain at segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/borges-users/attachments/20040502/e25bc44e/attachment-0001.bin
More information about the Borges-users
mailing list