Hi

 

Sorry for the delay.

 

Talking about the "Anemic Domain Model", I find this model very easy to
manage althought there's some common drawbacks.

 

About lazy loading in associated beans, the methodology is quite
straightforward. I show you an example:

 

Class Bean_Product

{

      Protected $id;

      Protected .

      Protected $manufacturerId; // needed if we want to load manufacturer
bean later, 

as the database product table will have the manufacturer_id column

      Protected $manufacturer; // Bean

 

      .

      Public function getManufacturer()

      {

            If($this->manufacturer == null) {

                  $this->manufacturer =
Model_Manufacturer::fetch($this->manufacturerId);

            }

            Return $this->manufacturer;

      }

}

 

Class Model_Manufacturer

{

      Public static function fetch($id)

{

            // do some checkings

            // get the row from database

            // fill the bean

            // return the bean

      }

}

 

As you can see, this approach makes the Model responsible of fetching data
and filling Beans, but not only from controllers but from beans too.

 

Models always fetches data, the Beans does not contain logic. With this
simple Bean structure, I can share Data Beans with services or another
applications, as if they are Data Transfer Objects.

 

I didn't know this design was called "Anemic Domain Model". Could you share
your model design? I always want to improve my designs.

 

Thanks.

 

  _____  

De: Kevin Young [mailto:[email protected]] 
Enviado el: jueves, 18 de diciembre de 2008 17:02
Para: [email protected]
Asunto: Re: Another Model Design Thread (Zend MVC)

 

Hi Xavier,

 

Sorry, to bother you.

 

I replied to a post of yours on the Zend Framework mailing list and I was
not sure if you noticed. But I was really interested in hearing back from
you on the topic.

 

Reply 1

http://www.nabble.com/Re:-Another-Model-Design-Thread-p21058411.html

 

Reply 2

http://www.nabble.com/Re:-Another-Model-Design-Thread-p21058537.html

 

 

I would appreciate any guidance you could provide.

 

 

Regards,

Kevin Young

Reply via email to