tags:

views:

61

answers:

2

I have a message class that I use like so:

RedirectMsg::go('somepage.php', MessageType::ERROR, 'Your message here.');

Would it be better to use a regular function? Or is this a personal preference issue?

redirectMsg('somepage.php', MessageType::ERROR, 'Your message here.');
A: 

This is generally a personal preference thing. It also depends on the scope of your application. You can afford to "organize" less in a smaller app and just save yourself the typing.

Jakub Hampl
I personally prefer just to have it as simple functions, however many PHP frameworks (for example) use the static method way.
Jakub Hampl
+4  A: 

Objects Classes help provide a sudo pseudo-namespace for functions so that they don't overlap, which can be very helpful. Have a large number of functions in the global namespace is a naming disaster waiting to happen. If you're using PHP 5.3 you might want to look into namespaces.

Kendall Hopkins
I'd love to have a `sudo namespace` command! In the meantime, you probably mean "pseudo". ;-)
deceze
Thanks Kendall. I think this is wise.
letseatfood
@deceze `sudo` make me a namespace
Kendall Hopkins
"Objects help provide..." - no objects involved here. Should be "Classes".
VolkerK