<rdf:RDF
    xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
    xmlns:s='http://snipsnap.org/rdf/snip-schema#'
    xml:base='http://www.peerbox.com:8668/rdf'>
    <s:Snip rdf:about='http://www.peerbox.com:8668/rdf#comment-start/2006-01-20/1-2'
         s:name='comment-start/2006-01-20/1-2'>
        <s:content>I recently implemented this very pattern in a web application, in which I wanted to represent the current state (in the sense of REST) in such a way that I could say&#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;state.getNextPage().getRest()&#xD;&#xA;{code}&#xD;&#xA;&#xD;&#xA;to get the URL which represents &quot;the next page of results&quot;.&#xD;&#xA;&#xD;&#xA;In order to permit construction of arbitrary, unknown future subclasses, I use the factory method.&#xD;&#xA;&#xD;&#xA;{code}&#xD;&#xA;// pseudo-code&#xD;&#xA;class StateWithPage implements State {&#xD;&#xA;  public State getNextPage() {&#xD;&#xA;     return createState(this.page + 1);&#xD;&#xA;  }&#xD;&#xA;&#xD;&#xA;  protected State createState(final int page) {&#xD;&#xA;     return new StateWithPage(page);&#xD;&#xA;  }&#xD;&#xA;}&#xD;&#xA;&#xD;&#xA;class StateWithPageAndColor extends StateWithPage {&#xD;&#xA;  protected State createState(final int page) {&#xD;&#xA;    return new StateWithPageAndColor(page, this.color);&#xD;&#xA;  }&#xD;&#xA;}&#xD;&#xA;{code}</s:content>
        <s:cUser>Jonathan Feinberg</s:cUser>
        <s:oUser>Jonathan Feinberg</s:oUser>
        <s:mUser>Jonathan Feinberg</s:mUser>
        <s:mTime>2006-02-22 16:10:38.172</s:mTime>
        <s:cTime>2006-02-22 16:10:38.044</s:cTime>
        <s:comments
             rdf:type='http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag'/>
        <s:snipLinks>
            <rdf:Bag>
                <rdf:li rdf:resource='http://www.peerbox.com:8668/rdf#Jonathan Feinberg'/>
            </rdf:Bag>
        </s:snipLinks>
        <s:attachments
             rdf:type='http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag'/>
    </s:Snip>
</rdf:RDF>
