The fate of class suffixes in 5.3

Before PHP 5.3 was released, many programmers would suffix their classnames with the package and or module that it pertains to. For example, SessionHelper, UsersController, CommentModel, so on and so forth. But with the recent upgrade to namespaces, are these types of suffixes still required?

// Current Practice
SessionHelper();

// Namespace Practice
\app\libs\helpers\Session();

// Redundant Practice
\app\libs\helpers\SessionHelper();

That's one of many dilemma's I am running into right now when dealing with past practices and theories, and applying them to newer code. Namespaces make the suffix redundant as the package is now part of the class name (unless you are aliasing the namespace). The only deal breaking reason I can think of right now as to keep suffixes; is when you are editing multiple files (or browsing a folder), as it helps identify files from each other. But on the other hand, how many times are you going to have multiple files opened name User? Maybe twice for the model and controller.

I'm mainly posting this entry to get input from everyone else and what you think the approach should be. Right now I'm going down the path of not suffixing my classes, as the similar file name is not that much of a problem or hindrance to me. If you have any convincing arguments, let me hear them (especially since this will apply to my newer scripts)!

3 Comments

  • @Lunks - While it is ugly, that is a pretty moronic thing to say seeing as how namespaces are a god send in the PHP world.

    .App.Helpers.Session
    ::App::Helpers::Session

    Aren't that great either. Back slashes make the most sense because namespaces work similar to a directory structure.
  • PHP 5.3 namespace syntax is so awful I do not intend to use it at all. It *feels* ugly.
  • I normally namespace my PHP 5.2 classes using the PEAR standard: App_Libs_Helpers_Session. I have rarely noticed a problem with multiple files being open, though I do use vim exclusively.