From: Roelof Wobben Date: 2012-09-24T20:13:47+09:00 Subject: Re: sandwhich principle (ruby koans) --_0a37391c-2216-4d6f-9adc-6392db5d7e54_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Oke=2C If I understand it right the principle is the same as the DRY metho= d Roelof > Date: Mon=2C 24 Sep 2012 17:29:34 +0900 > From: shortcutter@googlemail.com > Subject: Re: sandwhich principle (ruby koans) > To: ruby-talk@ruby-lang.org >=20 > On Mon=2C Sep 24=2C 2012 at 9:38 AM=2C Carlos Agarie wrote: > > Roelof=2C > > > > This principle says that when you have two pieces of code that are almo= st > > identical=2C except for the "middle" part=2C you can create a method th= at takes > > a block to fill the "middle" part. >=20 > Another pattern which has a similar structure and uses abstract > methods and inheritance is "template method": > http://en.wikipedia.org/wiki/Template_method_pattern >=20 > Although with template method the stress is more on having different > classes filling in portions of an algorithm with different > functionality. On a higher level of abstraction both patterns share > the property that part (or parts) of an algorithm are delegated to > another method / function which is called from the basic algorithm > implementation. >=20 > Kind regards >=20 > robert >=20 > --=20 > remember.guy do |as=2C often| as.you_can - without end > http://blog.rubybestpractices.com/ >=20 = --_0a37391c-2216-4d6f-9adc-6392db5d7e54_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Oke=2C
 =3B
If I understand it right the principle is the same&n= bsp=3Bas the DRY method
 =3B
Roelof

 =3B
>=3B Date: Mon=2C 24 Sep 2012 17:29:34 = +0900
>=3B From: shortcutter@googlemail.com
>=3B Subject: Re: san= dwhich principle (ruby koans)
>=3B To: ruby-talk@ruby-lang.org
>= =3B
>=3B On Mon=2C Sep 24=2C 2012 at 9:38 AM=2C Carlos Agarie <=3Bc= arlos.agarie@gmail.com>=3B wrote:
>=3B >=3B Roelof=2C
>=3B &g= t=3B
>=3B >=3B This principle says that when you have two pieces of = code that are almost
>=3B >=3B identical=2C except for the "middle" = part=2C you can create a method that takes
>=3B >=3B a block to fill= the "middle" part.
>=3B
>=3B Another pattern which has a simila= r structure and uses abstract
>=3B methods and inheritance is "templat= e method":
>=3B http://en.wikipedia.org/wiki/Template_method_pattern>=3B
>=3B Although with template method the stress is more on hav= ing different
>=3B classes filling in portions of an algorithm with di= fferent
>=3B functionality. On a higher level of abstraction both pat= terns share
>=3B the property that part (or parts) of an algorithm are= delegated to
>=3B another method / function which is called from the = basic algorithm
>=3B implementation.
>=3B
>=3B Kind regards=
>=3B
>=3B robert
>=3B
>=3B --
>=3B remember.gu= y do |as=2C often| as.you_can - without end
>=3B http://blog.rubybestp= ractices.com/
>=3B
= --_0a37391c-2216-4d6f-9adc-6392db5d7e54_--