--_0a37391c-2216-4d6f-9adc-6392db5d7e54_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


Oke,  If I understand it right the principle is the same as the DRY method  Roelof
 > Date: Mon, 24 Sep 2012 17:29:34 +0900
> From: shortcutter / googlemail.com
> Subject: Re: sandwhich principle (ruby koans)
> To: ruby-talk / ruby-lang.org
> 
> On Mon, Sep 24, 2012 at 9:38 AM, Carlos Agarie <carlos.agarie / gmail.com> wrote:
> > Roelof,
> >
> > This principle says that when you have two pieces of code that are almost
> > identical, except for the "middle" part, you can create a method that takes
> > a block to fill the "middle" part.
> 
> Another pattern which has a similar structure and uses abstract
> methods and inheritance is "template method":
> http://en.wikipedia.org/wiki/Template_method_pattern
> 
> 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.
> 
> Kind regards
> 
> robert
> 
> -- 
> remember.guy do |as, often| as.you_can - without end
> http://blog.rubybestpractices.com/
> 
 		 	   		  -_0a37391c-2216-4d6f-9adc-6392db5d7e54_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>
Oke, <BR>&nbsp;<BR>If I understand it right the principle is the same&nbsp;as the DRY method <BR>&nbsp;<BR>Roelof<BR><br>&nbsp;<BR><div><divd="SkyDrivePlaceholder"></div>&gt; Date: Mon, 24 Sep 2012 17:29:34 +0900<br>&gt; From: shortcutter / googlemail.com<br>&gt; Subject: Re: sandwhich principle (ruby koans)<br>&gt; To: ruby-talk / ruby-lang.org<br>&gt; <br>&gt; On Mon, Sep 24, 2012 at 9:38 AM, Carlos Agarie &lt;carlos.agarie / gmail.com&gt; wrote:<br>&gt; &gt; Roelof,<br>&gt; &gt;<br>&gt; &gt; This principle says that when you have two pieces of code that are almost<br>&gt; &gt; identical, except for the "middle" part, you can create a method that takes<br>&gt; &gt; a block to fillhe "middle" part.<br>&gt; <br>&gt; Another pattern which has a similar structure and uses abstract<br>&gt; methods and inheritance is "template method":<br>&gt; http://en.wikipedia.org/wiki/Template_method_pattern<br>&gt; <br>&gt; Although with template method the stress is more on having different<br>&gt; classes filling in portions of an algorithm with different<br>&gt; functionality.  On a higher level of abstraction both patterns share<br>&gt; the property that part (or parts) of an algorithm areelegated to<br>&gt; another method / function which is called from the basic algorithm<br>&gt; implementation.<br>&gt; <br>&gt; Kind regards<br>&gt; <br>&gt; robert<br>&gt; <br>&gt; -- <br>&gt; remember.guy do |as, often| as.you_can - without end<br>&gt; http://blog.rubybestpractices.com/<br>&gt; <br></div> 		 	   		  </div></body>
</html>-_0a37391c-2216-4d6f-9adc-6392db5d7e54_--