You are here: Re: [PHP] enterprise patterns headache « PHP « IT news, forums, messages
Re: [PHP] enterprise patterns headache

Posted by Richard Lynch on 10/04/00 11:13

On Wed, April 13, 2005 2:01 pm, Robert Janeczek said:

I can't claim a detailed understanding of what you are doing, and,
frankly, it sounds like you are creating a BUNCH of over-engineered
headache-inducing code without a good, proven need for it. YMVV.

That said, one thing I *did* understand and can comment on:

> Sample code:
> $company = CompanyMapper::find(1); // we have ghost inside $company
> //some other operations, but we don`t touch $company
> $company2 = CompanyMapper::findByName('Big Ltd.');
>
> Now let`s assume, that company with ID=1 has name Big Ltd. We have two
> independent copies of the same object what kinda sucks :] The problem is
> that both finding methods return ghosts and the second one doesn`t know
> his ID yet. If there would be only ID-based searching than Identity Map
> would detect it and caused returning the same instance, but it`s not...

So why not do this:
Make findByName look up the $ID with the query you already use, possibly
caching the other fields/data you use frequently in some kind of very temp
space: $row (array returned from query).
Then call CompanyMapper::find($ID, $row);
which uses the info it already has given for free in $row, but can also
check your cache of existing object, fill in any free data from $row, and
return the existing object if it's there.

> Unfortunately, we cannot afford to loose lazy load for those searching
> methods which use something different than ID. Our current solution is
> putting every ghost object inside handler object, because it allows us
> to switch object inside without rest of application noticing. This
> however requires many classes with nothing more than bunch of methods
> which transfer calls to another objects. We are working on piece of
> code, which will use Reflection to autogenerate these classes, but still
> it`s not very nice solution imho.

Perhaps a specialized object that manipulates/returns other objects based
on arguments is in order. Instead of a zillion objects that all do that
same thing, only one for each real object, you have one that handles all
the other objects the same way, but trying to find the same object in your
cache first, then digging deeper into lazy load (or whatever) to build it.

How certain are you that all this code is saving you *ANYTHING*?

Is it worth the development/maintenance expense?

Only you can answer those questions.

--
Like Music?
http://l-i-e.com/artists.htm

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация