How silly.  What is Zend_Registry, then?  Zend_Controller_Front?  They're
all singletons. Should all factories be implemented as instance methods,
too?
Let's say this class he's talking about returns an ad for a given set of
dimensions and providers.  What is so wrong with My_Ad::factory(), with a
view helper My_View_Helper_Ad ($this->ad()) that proxies to it (returning a
My_Ad_SomeNetwork object with render() and __toString() methods)?

-Matt

On Sun, Jun 21, 2009 at 4:50 PM, Karol Grecki <kgre...@gmail.com> wrote:

>
> "global functional object" sounds like a very fancy name for procedural
> code
> with global functions.
> Code like this will never be consistent with ZF and is generally considered
> bad.
> Deciding how to call a method should probably be the least of your
> concerns.
> You should also write PHP5 code if you want to be consistent with ZF.
>
> Karol
>
>
> howard chen wrote:
> >
> > Hello,
> >
> > It is not a 100% zfw question, but as I am coding under zfw, so I want
> > if my OO coding is consistent with the zfw.
> >
> >
> > Example:
> >
> > I have a Class - MyClass, it is a global functional object, has the
> > function foo() I need to call in several php files for a single HTTP
> > request.
> >
> > ============
> > class MyClass{
> >
> >     function MyClass () {
> >         $this->init();
> >     }
> >
> >     function &getInstance {
> >         static $instance;
> >
> >         if (!isset($instance)) {
> >             $instance = new MyClass();
> >         }
> >
> >         return $instance;
> >     }
> >
> >     function init() {
> >         // Some heavy init codes...
> >     }
> >
> >     function foo() {
> >         // core function
> >     }
> >
> > }
> > ============
> >
> >
> > Which one you prefer:
> >
> >
> > 1. Call as global class:
> >
> >
> > $data = MyCalss::foo();  // put init() in bootstrap
> >
> >
> > 2. Call as singleton
> >
> > $myClass =& MyClass::getInstance();
> > $myClass->foo();
> >
> > 3. Call as new object
> >
> > $myClass = new MyClass();
> > $myClass->foo();
> >
> >
> >
> > which method you prefer?
> >
> >
> > Thanks.
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/ZFW-OO-coding-guideline-tp24136353p24140060.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
>

Reply via email to