On 13-09-04 09:06 PM, Micky Hulse wrote:
Hi Rodrigo, thanks for the help, I really appreciate it!
On Wed, Sep 4, 2013 at 5:55 PM, Rodrigo Santos
Hi, first, sorry for the bad English.
Not bad at all! Very clear and well written reply (heck, it's better
than my native English writing), so thank you! :)
Yes, at least, as far as I know, this is the perfect way to do what you want
to do. Think like this: when you instanciate a class, you are allocating
memory. If you don't need any information stored, then you don't need to
allocate memory, right? So, it's is logic to have a class that you will call
only one fragment when you need it, rather than load the entire class just
for one method.
Interesting! That makes a lot of sense.
Now you've piqued my interests! :)
I was going to head down a different path, but you've inspired me to
further explore the use of static methods/properties/variables/other.
A part of me just wants to learn more about PHP OOP, and using static
members is something I've not explored much. Seems like a simple
functional utility class would be a good time to play and learn more.
Just be careful to organize your utility methods by by meaning. Don't put a
method that make dating stuff and a method that write a random string in the
same class. By doing so, you are breaking the object orientation purpose.
Excellent tip! Thank you Rodrigo! I really appreciate the tips/advice
and inspiration. :)
I'll second Rodrigo's opinion, but would like to comment that the name
of the class is misleading since it's called "Singleton". The singleton
pattern is used when you only ever want one instantiation of a class. In
your case you are using static methods, the object never needs to be
instantiated and so it doesn't fit this pattern. What you are creating
is far more consistent with the utility pattern.
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php