2009/11/10 Paladin <arlen....@gmail.com>:
>
> I'm almost sorry to be so blunt about it, but this is a particularly
> egregious example of class abuse. Let's take a walk through it, shall
> we, while I ask the impertinent questions:
>
> sendmail, sendAdminMail: There's already a perfectly fine JMail class,
> and these functions are interfaces to it. They belong as member
> methods of JMail, they have no reason to exist apart from it. (If you
> want to get *really* picky about it, every object that is allowed to
> send mail should have a "sendmail" somewhere in its inheritance tree,
> which would consist of a getMailer call to JFactory and a send, just
> two lines of code -- or even a single line like JFactory->getMailer
> ().send( arglist). Everything else belongs in JMail.)
Yep.
>
> getHash: an MD5 of a config value. Belongs either in the interface for
> the config values (JRegistry) or the class that value is used. (see
> next)
Agree with moving this to JApplication::getHash
>
> getToken - simply a session hash, belongs in JSession. And while we're
> on the subject, why two different anti-spoof hashes? If one is for
> session use, and getHash() is for the rest of the app, shouldn't
> getHash be in JApplication?
Agree generally. I think there's possibly some merit in keeping the
clear token and then having one for usage in forms. So maybe
JUtility::getToken moves to JSession::getFormToken which is static.
Not 100% sure on that one myself other than it should change.
>
> parseAttributes - "for XML style attributes" Belongs in simpleXML,
> then, right? Or, if actually used in processing many types of
> documents (as it actually seems to be) then it should be in the
> inheritance tree for processing those documents. Either way, not here.
Actually it's for parsing a=1&b=2, etc. Probably something native we
can use or bolt it onto the JUri class.
>
> isWinOS - Don't have a single instance of it being called, but even if
> so, shouldn't it be in JApplication? (and why PHP_OS rather than the
> recommended php_uname('s')?)
Thought is was used in JFile or something. I think JApplication is
fine if it's necessary at all.
>
> dump - Another unused function. The fact it might be useful while
> debugging implies it should be in a "debug" class that's only loaded
> when debugging is on, and not in a class that's always loaded.
Nuke it.
>
> array_unshift_ref -- AFAICT, this is used only by stream to push a
> resource on the top of a stack. If that's the case, move it to stream.
> If not, create a data class for the data type that will require this
> and put it there.
Yep, replace it with some real code in the right spot.
> return_bytes -- AFAICT used only in InstallerModelWarnings. Move it
> there. Or into an inheritance chain above there so it's available to
> whatever else might be using it.
Move as suggested.
>
> Recommendation for this class is to empty it completely of every
> function Joomla plans on continuing to use, and leave only deprecated
> functions and proxies for the moved functions, with an eye toward
> eliminating the entire class in the future.
Agree. Deprecate the whole thing.
Regards,
Andrew Eddie
http://www.theartofjoomla.com - the art of becoming a Joomla developer
I think we should mount that on a plaque at the NY Devcon and chant it
down the streets of Manhattan :) Love it!