Reply to Re: Accessing Class Method

Your name:

Reply:


Posted by Steve on 09/17/07 17:51

"RageARC" <ragearc@gmail.com> wrote in message
news:1190049520.484592.326400@57g2000hsv.googlegroups.com...
> Well, Steve, I called it main_class just for an example purpose. The
> fact is this is supposed to be a class that holds several class in
> only one, so I could call:
>
> $main_class->database->method($args);
> $main_class->html->make_form($args);

if main is static, only the syntaxt would change:

main::db->method

if dal is static as well, then:

main::db::interface();


> Understood? I think this is much better than having several variables
> for different classes, as it groups the whole functionality of all
> classes into only one variable. If you find there is a way to do this
> better, please, do tell me.

true, however if that's the only way you allow access to them, then you
loose the ability to reuse part or all of their functionality. that may be
no big deal in reality, and i can't tell from your example, however that
should always be a consideration when making such choices in design.

i did neglect to see your html code where it consumes dal. you'd want to
require_once 'dal.php'. whether or not you make dal or html statically
interfaced is up to you. nothing says you can't create a dal when html is
constructed. the main class c/would kick all of that off when you
constructed it via the initialize() function. that would allow you to reuse
the dal and html classes independently but still get the result you're
looking for when called via the static main_class object. clear as mud?

make sense?

btw, i was giving you a hard time about the names...no biggie.

[Back to original 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

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