You are here: Re: Accessing Class Method « PHP Programming Language « IT news, forums, messages
Re: Accessing Class Method

Posted by Steve on 09/17/07 20:35

> On Sep 17, 10:36 pm, "Steve" <no....@example.com> wrote:
>> > Btw. Try to write an OO application in a manner that would not require
>> > the require_once statement, but rather a plain require. In part,
>> > because it's faster, but mainly because it will force you to write
>> > your applications in a much straightforward manner. Maybe
>> > straightforward isn't the word here, but I'm tired as hell...
>>
>> if both main_class and html require dal.php and could be used in the same
>> script, require_once is better and produces less parsing in php...and is
>> therefore faster than php having to check if it loaded a file already or
>> not. THAT is straightforward...probably not the word you're looking for.
>


"NoDude" <nodude@gmail.com> wrote in message
news:1190059436.589239.53770@22g2000hsm.googlegroups.com...
>I think you're confusing require_once with require. require_once has
> to check if a file has been loaded or not, require does a
> straightforward require - hence the speed boost.


no, i'm thinking of the correct thing. and it entirely depends on what your
errors are set to before you'll get that error. i'm not a noob and i know
when and why to use either. there is NO significant speed boost using
either, but a world of problems in an oop context by not using one.

> About writing straightforward scripts. Using require instead of
> require_once will cause php to throw an error the second you try to
> redefine a class you already have (which will happen if you require a
> file with the same class declaration twice). By all all means, use
> require_once, it's a language statement, it's useful when you need to
> use it, BUT a thought out OOP should _not_ need the *_once statements.

'thought' out? that's bullshit. if you are producing truly loosely coupled
objects, you will inevitably be loading class files (requiring) where you'd
likely produce the errors because of an object's reuse! require_once is a
FORMAL means that averts those errors. if you are THINKING about oop and
thinking CLEARLY, you'd notice the pattern lends itself more to *_once than
include/require alone!

you produce a time-tested (as in speed differencial) benefit between require
and require_once that show a significant load difference, and i'll be very
suprised. either way, show me your mechanism that allows loose coupling,
loads any required resource without one class knowing whether or not another
resource is consumed by another caller/object, and is as easily implemented
as *_once, and then we'll have something to talk about.

> The flow of an OOP using a robust design paradigm (like MVC for
> instance), should allow for full knowledge of which class gets
> included where, if not you're looking at a need for a singleton, if
> that doesn't help - delegate to the method required.


sorry, php is far from a robust design paradigm when it comes to oop
(comparatively), so for now, require_once is a one-line, quick means to load
a resource without having to allow for 'full knowledge' - which is ANTI-OOP
anyway.

> Like I said, I'm not imposing the sole usage of require over require
> once (although I prefer it), I'm also not saying you should rewrite
> existing code to gain the 0.xx ms advantage of require_once over
> require.

design v. time where time == 1 nano-second. hmmm...design wins.

> What I _am_ saying is that using plain require over require once has
> solid benefits. And heck, if you can whine about his naming
> conventions, why can't I about your coding style :)

you have no idea what my coding style is. when dealing with class files that
are to be used within other class files, it is ALWAYS the best option to
require_once.

why can't you? well, first, because you don't know it. second, your
reasoning is not sound. that's why i wouldn't...but you go right ahead.

btw, why are you top-posting?

 

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

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