Simple question: when should static classes be used?
OOP: When should static classes be used?
Collapse
X
-
The best way for me to tell you is by example: Date class.
I've created my own date class that I don't always need to initialize an instance of. Perhaps I need the difference between two dates, a conversion in format.
The reason I started doing this is because I noticed in my general functions file I had over 10 functions that were all date related and decided to put them in a class and call it when I want.
echo Date::convertUS toMySQL($date = "04/30/2009", $includeTime = true)
// outputs: 2009-04-30 00:00:00
Resource:
Cheers mate,
Dan -
Comment
-
Comment
-
This is an idea that I thought about for our Framework, Please remember to bring this up, if I forget. This could replace client.php config file altogether.example: Registry Pattern (text is in German, but the source code is quite self-explanatory)Comment
Comment