Task #2515

Inconsistent class names in sub namespaces

Added by Robert Lemke over 12 years ago. Updated over 10 years ago.

Status:
Resolved
Priority:
Must have
Assignee:
Category:
-
Start date:
2009-01-26
Due date:
% Done:

100%

Estimated time:
Sprint:
PHP Version:
Has patch:
Complexity:

Description

In the current code base the naming of classes in sub namespaces is not consistent. After a short discussion we came up with the following rules:

- The unqualified class name must be meant literally even without the namespace. 
- The main purpose of namespaces is categorization and ordering

Thes rules prevent us from running into conflicts with reserved keywords.

Bad examples:

Fully qualified class name            Unqualified class name     Remarks
--------------------------------------------------------------------------------------------------------------------
\F3\FLOW3\Session\PHP                 PHP                        The class is not a representation of PHP!
\F3\FLOW3\Cache\Backend\File          File                       The class doesn't represent a file!
\F3\FLOW3\Session\Interface           Interface                  Not allowed, "Interface" is a reserved keyword
\F3\Foo\Controller\Default            Default                    Not allowed, "Default" is a reserved keyword

Good examples:

Fully qualified class name            Unqualified class name     Remarks
--------------------------------------------------------------------------------------------------------------------
\F3\FLOW3\Session\PHPSession          PHPSession                 That's a PHP Session
\F3\FLOW3\Cache\Backend\FileBackend   FileBackend                A File Backend
\F3\FLOW3\Session\SessionInterface    SessionInterface           Interface for a session
\F3\Foo\Controller\DefaultController  DefaultController          The default controller

Edge cases:

Fully qualified class name            Unqualified class name     Remarks
--------------------------------------------------------------------------------------------------------------------
\F3\FLOW3\Object\Manager              Manager                    If it's the only manager in that namespace, it's okay
\F3\Foo\Bar\Builder                   Builder                    If it's clear what the builder builds (Bar?), it's okay
\F3\FLOW3\Object\Builder              Builder                    Problem: There's a "ConfigurationBuilder" in the same
                                                                 namespace, therefore better rename the Builder to
                                                                 ObjectBuilder
\F3\FLOW3\Object\Factory              Factory                    As long as it is the only factory in that namespace, okay
\F3\FLOW3\MVC\ControllerInterface     ControllerInterface        Consequently the interface belongs to all the
                                                                 controllers in the Controller sub namespace
\F3\FLOW3\MVC\Controller\ControllerInterface                     Better
\F3\FLOW3\Cache\AbstractBackend       AbstractBackend            Same here: In reality this class belongs to the backends
\F3\FLOW3\Cache\Backend\AbstractBackend                          Better
Scope of this ticket:
  1. Refactor class names which don't follow the above rules.
  2. Add the above rules to the CGL.
#1

Updated by Karsten Dambekalns almost 12 years ago

  • Assignee set to Robert Lemke
#2

Updated by Robert Lemke almost 12 years ago

  • Status changed from Accepted to Resolved
  • % Done changed from 0 to 100

Applied in changeset r2282.

Also available in: Atom PDF