<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://mirmodynamics.com/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
  <title>Mirmo Dynamics - Tag - pattern</title>
  <link>http://mirmodynamics.com/</link>
  <atom:link href="http://mirmodynamics.com/feed/tag/pattern/rss2" rel="self" type="application/rss+xml"/>
  <description>Si tu kiffes pas reunoi, t'écoutes pas et puis c'est tout.</description>
  <language>en</language>
  <pubDate>Sun, 14 Mar 2010 19:59:01 +0100</pubDate>
  <copyright>2003-2009 &amp;copy; Geoffrey Bachelet</copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>Extending Zend_Controller_Router_Route: the singleton problem.</title>
    <link>http://mirmodynamics.com/post/2007/11/05/Extending-Zend_Controller_Router_Route%3A-the-singleton-problem</link>
    <guid isPermaLink="false">urn:md5:639fef9d7c01edc0e63ee3f2c2a5c823</guid>
    <pubDate>Mon, 05 Nov 2007 14:37:00 +0100</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>annoying</category><category>dry</category><category>oop</category><category>pattern</category><category>php5</category><category>route</category><category>self</category><category>singleton</category><category>zend framework</category>    
    <description>    &lt;p&gt;Today I ran into an issue while extending &lt;code&gt;Zend_Controller_Router_Route&lt;/code&gt;. I wanted to add a little path pre/post processing in the &lt;code&gt;match()&lt;/code&gt; and &lt;code&gt;assemble()&lt;/code&gt; methods, so I just extended the Route class to add my tiny bits of code into the methods. Except it did not work at all. After a few debuging, it turned out that the Router uses &lt;code&gt;Zend_Controller_Router_Route::getInstance()&lt;/code&gt; to retrieve a route object, which uses a &lt;code&gt;new self();&lt;/code&gt; statement to instantiate the route object. Problem is that &lt;code&gt;self&lt;/code&gt; always refers to the current class definition we're in, if the method is called from a child class, without being overloaded, self will refer to the wrong class.&lt;/p&gt;


&lt;p&gt;Example:&lt;/p&gt;
&lt;pre&gt;
[php]
class Foo {
	public static function getInstance() {
		return new self;
	}
}

class Bar extends Foo {}

var_dump(Bar::getClass());
&lt;/pre&gt;


&lt;p&gt;echoes something like:&lt;/p&gt;

&lt;pre&gt;
object(Foo)#1 (0) {
}
&lt;/pre&gt;


&lt;p&gt;Which is fscking wrong IMHO. A quick workaround is to overload the &lt;code&gt;getInstance&lt;/code&gt; method, which is what I call pretty annoying as it does not follow the DRY principle.&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2007/11/05/Extending-Zend_Controller_Router_Route%3A-the-singleton-problem#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2007/11/05/Extending-Zend_Controller_Router_Route%3A-the-singleton-problem#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1072</wfw:commentRss>
      </item>
    
  <item>
    <title>Stripping the logic: the Transfer Object</title>
    <link>http://mirmodynamics.com/post/2007/08/11/Stripping-the-logic%3A-the-Transfert-Object</link>
    <guid isPermaLink="false">urn:md5:fb705efad8749c9d2c20f85702147c29</guid>
    <pubDate>Sat, 11 Aug 2007 11:56:00 +0200</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>j2ee</category><category>oop</category><category>p of eaa</category><category>pattern</category><category>php</category><category>transfer object</category><category>zend framework</category>    
    <description>    &lt;p&gt;Sometimes you have to pass an object data to another object, or to another layer of your application (who said controller/view ?), while ensuring that the receiving entity will not be able to run business code encapsulated in your class. In the Zend Framework, several objects provide a &lt;code&gt;toArray&lt;/code&gt; method, but that is not always sufficient as sometimes you'd like to keep with the &lt;code&gt;$object-&amp;gt;varname&lt;/code&gt; syntax.&lt;/p&gt;


&lt;p&gt;That is where the Transfer Object arrives. While the preceding definition is not exact (that's not the real purpose of the Transfert Object in the J2EE spirit), This is the most common use that PHP Developers can make of it nowadays I think. So I came up with a &lt;a href=&quot;http://svn.riskle.com/library/Riskle/Pattern/TransferObject.php&quot;&gt;very light implementation of a concept&lt;/a&gt; which I hope can prove useful for any folks getting by there.&lt;/p&gt;


&lt;p&gt;See also:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Martin Fowler's &lt;a href=&quot;http://www.martinfowler.com/eaaCatalog/valueObject.html&quot;&gt;Value Object&lt;/a&gt; and &lt;a href=&quot;http://www.martinfowler.com/eaaCatalog/dataTransferObject.html&quot;&gt;Data Transfer Object&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://java.sun.com/blueprints/corej2eepatterns/Patterns/TransferObject.html&quot;&gt;The Transfert Object as a Core J2EE Pattern&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2007/08/11/Stripping-the-logic%3A-the-Transfert-Object#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2007/08/11/Stripping-the-logic%3A-the-Transfert-Object#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/925</wfw:commentRss>
      </item>
    
  <item>
    <title>Zend Framework Pagination reloaded</title>
    <link>http://mirmodynamics.com/post/2007/07/31/Zend-Framework-Pagination-reloaded</link>
    <guid isPermaLink="false">urn:md5:ff2795a69d87c7651a3e739a14720d82</guid>
    <pubDate>Tue, 31 Jul 2007 11:33:00 +0200</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Coding</category>
        <category>pagination</category><category>pattern</category><category>php</category><category>proxy</category><category>zend framework</category><category>zend_db_table</category>    
    <description>    &lt;p&gt;&lt;strong&gt;UPDATE&lt;/strong&gt;&lt;/p&gt;


&lt;p&gt;&lt;a href=&quot;http://fashion.hosmoz.net/post/2007/09/23/Zend-Framework-Pagination-third-strike&quot;&gt;A new version of this component is available&lt;/a&gt;.&lt;/p&gt;



&lt;p&gt;I have a &lt;a href=&quot;http://svn.riskle.com/library/Riskle/Db/Table/Paginate.php&quot;&gt;new version of my pagination component&lt;/a&gt; which solve &lt;a href=&quot;http://fashion.hosmoz.net/post/2007/07/15/Pagination-with-the-Zend-Framework#c2757&quot;&gt;the issue previously pointed out&lt;/a&gt; by &lt;a href=&quot;http://totalement.geek.oupas.fr/&quot;&gt;Guy&lt;/a&gt;. This update comes along with &lt;a href=&quot;http://svn.riskle.com/library/Riskle/Db/Table.php&quot;&gt;a subclassed version of Zend_Db_Table&lt;/a&gt; which allows counting and specific columns selection respectively via the &lt;code&gt;fetchCount()&lt;/code&gt; and &lt;code&gt;fetchCols()&lt;/code&gt; methods. Btw, the &lt;code&gt;fetchCols()&lt;/code&gt; method is &lt;strong&gt;very&lt;/strong&gt; hackish at the moment, and I'll certainly end up with rewriting it using a plain &lt;code&gt;Zend_Db_Select&lt;/code&gt; statement.&lt;/p&gt;


&lt;p&gt;As always, any comment is appreciated. I'm thinking of subclassing the Rowset class to fill it with pagination info getters like &lt;code&gt;getPageCount()&lt;/code&gt;, &lt;code&gt;getNextPage()&lt;/code&gt;, etc, like in &lt;em&gt;Symfony&lt;/em&gt; for those knowing, instead of relying on a &lt;code&gt;getPaginationInfo()&lt;/code&gt; method. Future improvements will also include more view helper magic.&lt;/p&gt;


&lt;p&gt;Also, I came up with a small new &lt;code&gt;Riskle_Pattern&lt;/code&gt; namespace which I use to &lt;a href=&quot;http://svn.riskle.com/library/Riskle/Pattern/Proxy.php&quot;&gt;implement commonly used patterns&lt;/a&gt;, such as the &lt;a href=&quot;http://en.wikipedia.org/wiki/Proxy_pattern&quot;&gt;Proxy Pattern&lt;/a&gt;. I'm not yet sure of the pertinence of this thing, so any comments are yet again very much appreciated on this topic :-)&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2007/07/31/Zend-Framework-Pagination-reloaded#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2007/07/31/Zend-Framework-Pagination-reloaded#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/909</wfw:commentRss>
      </item>
    
</channel>
</rss>