From: Michael 'entropie' Trommer Date: 2006-01-10T03:36:29+09:00 Subject: Re: state pattern? --HcAYCG3uE/tztfnV Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello Robert, * Robert Klemme (bob.news@gmx.net) wrote: > Michael 'entropie' Trommer wrote: > >Hello, > > > >I found this State-pattern example on [1], and was interested to > >find a way to make this more useable for standard classes (not just > >servers as in the example) > > > >I'am not so skilled in OO coding and ruby, so iam interested what you > >all think. (and is it another implementation of the state pattern or > >iam on the > >wrong path?) >=20 > Hm, I think you probably did not get there completely. For example the= =20 > toggle state metchod is typically implemented in the each state class=20 > (every state knows the state that follows him under certain conditions,= =20 > like a finite state automata distributed across several classes). Also= =20 > inheriting TrueClass and FalseClass is generally not a good idea (instanc= es=20 > of FalseClass's subclass won't be treated as false). Ok. > [...] > Other optimizations are also possible, for example caching state > instance =20 > if there are a lot state changes and they should be fast. Thanks much! I will take a deeper look. This was very helpful. So long -- Michael 'entropie' Trommer; http://ackro.org ruby -e "0.upto((a=3D'njduspAhnbjm/dpn').size-1){|x| a[x]-=3D1}; p 'mailto:= '+a" --HcAYCG3uE/tztfnV Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2 (GNU/Linux) iD8DBQFDwq0cBBd8ye5RguQRAiRWAJ4oZbvX67cqT0HcuKI0Od28LyvKkQCfYQiY pZ5rDCr6CnuKvxCOXHdTUNw= =xyxZ -----END PGP SIGNATURE----- --HcAYCG3uE/tztfnV--