Task #2515

Inconsistent class names in sub namespaces

Added by Robert Lemke over 6 years ago. Updated almost 5 years ago.

Status:Resolved Start date:2009-01-26
Priority:Must have Due date:
Assigned To:Robert Lemke % Done:

100%

Category:-
Target version:TYPO3 Flow Base Distribution - 1.0 alpha 1
Sprint: Has patch:
PHP Version: 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.

Associated revisions

Revision e3afde5a
Added by Robert Lemke over 6 years ago

  • Testing: Fixed the initialization sequence in the TestRunner which didn't work anymore since the last modifications on the session init in the FLOW3 bootstrap
  • FLOW3: (Session) Renamed the classes ...\Session\PHP and ...\Session\Transient to ...\Session\PHPSession and ...\Session\TransientSession respectively. Addresses #2515

Revision 4947ad13
Added by Robert Lemke over 6 years ago

  • FLOW3: (MVC) Renamed the setSettings() method of the AbstractController to injectSettings() in order to use the new settings injection feature
  • FLOW3: (MVC) Moved the Controller Interface to the Controller namespace. Addresses #2515
  • FLOW3: (Utility) Removed the REQUEST_METHOD_* constants in the Environment class
  • FLOW3: (Utility) Renamed the getPOSTArguments and getGETArguments methods to getRawPOSTArguments and getRawGETArguments respectively
  • FLOW3: (Utility) Introduced a new method getRawServerEnvironment to the Environment API

Revision bfd69a43
Added by Karsten Dambekalns over 6 years ago

FLOW3:
  • moved and renamed some cache backend classes and interfaces, refs #2515
Widget:
  • adjusted one reference to Cache\Backend\File to the new name

Revision 8d6621a3
Added by Karsten Dambekalns over 6 years ago

FLOW3:
  • moved and renamed some Log backend classes and interfaces, refs #2515

Revision 996d4474
Added by Karsten Dambekalns over 6 years ago

FLOW3:
  • moved and renamed cache frontend classes and interfaces, refs #2515

Revision 671e4922
Added by Robert Lemke over 6 years ago

  • FLOW3: (MVC) Moved the ViewInterface into the View sub namespace. Addresses #2515
  • FLOW3: (MVC) Added a ControllerInterface to decouple classes using controllers from the AbstractController
  • FLOW3: (MVC) Merged the RequestHandlingController into the AbstractController. Still needs further cleanup and some tests are currently disabled.
  • FLOW3: (MVC) Wrote a proper testcase for the dispatcher

Revision 6087b575
Added by Robert Lemke over 6 years ago

  • FLOW3: (MVC) Moved the ConverterInterface into the correct namespace. Addresses #2515
  • FLOW3: (Utility) Added a new function getFileContents() to the Files library. Preferibly use this function instead of PHP's built-in file_get_contents() function because it will handle warnings and errors more gracefully.
  • Fluid: Cleaned up and partly refactored the TemplateView. Especially fixed the error prone comparisons (see #2536). There are still some skeletons in the closet and especially the unit tests badly need some improvements (more / proper use of mock objects, no functional test but unit tests etc.).

Revision da0d9617
Added by Karsten Dambekalns about 6 years ago

FLOW3:
  • added better examples and more explanations about namespace/class naming to CGL, refs #2515

Revision e9f23fb2
Added by Robert Lemke about 6 years ago

  • FLOW3: Renamed a few classes / moved them in the namespaces hierarchy to make naming more consistent. Resolves #2515
  • FLOW3: (MVC) Removed the AbstractWidget

History

#1 Updated by Karsten Dambekalns about 6 years ago

  • Assigned To set to Robert Lemke

#2 Updated by Robert Lemke about 6 years ago

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

Applied in changeset r2282.

Also available in: Atom PDF