You are here: Re: bug or feature? (OO design/languages) « PHP Programming Language « IT news, forums, messages
Re: bug or feature? (OO design/languages)

Posted by raf on 09/17/05 23:39

[my feeble attempts to debug PHP code snipped]
> My delima is this... let's say you wanted to do something like this in
> a class, and you needed all 3 of these vars to be defined.
>
> class MyClass4
> {
> var $one = array(1,2);
> var $two = array(3,4);
> var $three= array($one, $two); // a two dimensional array.
> // ... more code below
> }
>
> But you knew that these would always remain the same, and there was no
> need for putting them in every class. Meaning, if they are not static,
> it's just a waste of space.

First, your descriptive naming conventions don't help in understanding
the intent of your code.

Second, what do you mean "always remain the same?" Do you mean that
every single instance of MyClass4 shares the exact same single instance
of each of those arrays?

If so, might it be worth considering factoring out the array and using a
Singleton pattern for whatever they represent?

If not, rethink your design. And your naming conventions.'

> Also, there are no static initializer blocks like java.

Makes me wonder why people flock to use PHP then ;-)


> Is there a correct way to define this in the class this without wasting
> space?

See my suggestion above...

raf

 

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

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