You are here: Re: Constructor as a "Reset" Button « PHP Programming Language « IT news, forums, messages
Re: Constructor as a "Reset" Button

Posted by Sanders Kaufman on 07/25/07 18:02

Toby A Inkster wrote:
> Sanders Kaufman wrote:
>
>> In your case, every time my object is initialized, it would make TWO
>> function calls, instead of one - one to the constructor, and one to the
>> init().
>
> http://www.google.co.uk/search?q=premature+optimisation
>
> For heaven's sake, this is a *database* class. The overhead of an extra
> function call is the *least* of your worries.

Yeah - it's not the biggest performance hit ever, is it?
But a core design principle is to not use resources unnecessarily - so
calling TWO functions each time an object is created would violate that
principle.

OOP design principles are a *desirable* thing - but performance is an
imperative.



> Whenever you have to choose between code efficiency and readability,
> choose readability: development time is more expensive than CPU time.

I don't see it as being LESS readable.

Indeed, by calling it directly - instead of calling a reinit that calls
the constructor (or vice versa) it actually reduces the complexity of
the readability.

 

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

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