[TYPO3-50-general] Common namings for variables with path-content

Malte Jansen mail at maltejansen.de
Mon Jan 12 14:51:49 CET 2009


Hi
Robert Lemke schrieb:
> Hi Malte,
> 
> Am 12.01.2009 um 12:06 schrieb Malte Jansen:
> 
>>>> So for the class-part, would suggest:
>>>>
>>>> namespace F3\MyPackage\;
>>>> class MyClass {}
>>>>
>>>> => "className" == MyClass
>>>> => "class" == F3\MyPackage\MyClass  (PHP: __CLASS__)
>>>
>>> currently $class in FLOW3 means ReflectionClass($className), $method
>>> means ReflectionMethod($methodName) etc.
>>
>> I would suggest
>> $reflectionClass = Reflection_ReflectionClass($class)
>> like $objectFactory = Object_Factory($class)
> 
> The rule we have is to take variable names as literal as possible, so if 
> you
> have a variable called $objectFactory it contains an object which is an
> Object Factory. In your example $class does not contain a class (or object
> thereof) but the name of the class.
I thought $objectFactory is called because of the Component "Object" and 
  its className "Factory"
Same for the PackageManager $packageManager etc.
I haven't found an object starts with $object, just when variable might 
contain different objects-types.
So, the pattern to seems to be ${component}{ClassName} for an variable 
containing an object for the source of FLOW3.

Or is my definition of "component" wrong
Component => Packages/FLOW3/Classes/MyComponent

IMO "$reflectionClass = ReflectionClass($class)" is more consistent

> 
>> We should stic closer to PHP...
> 
> ... not always a good thing because PHP is not famous for its consistent 
> and
> intuitive naming ;-)
> 
>> $class == __CLASS__
>> $class == $namespace . $className (like $file == $path . $fileName)
>> $class == __NAMESPACE__ . $className
> 
> I'd say that $className should in most cases be __CLASS__, i.e. the full 
> qualified
> class name without leading backslash. That's what I'd expect most of the 
> time.
With your definition I would expect $fileName containing the path and 
filename.
IMO $className == __CLASS__ is contradictory to the definitions, you 
wrote about "directoryName" and "fileName".
The namespace is relative new. So there no real definitions until now. I 
would describe the namespace somekind of path to a certain className, 
because it's using (back) slash as delimiter.

So let's keep it simple. I don't know every detail

> 
>> basically in FLOW3
>> we are useing $componentClassName for an object.
> 
> we don't have something like $componentClassName. What we do have is 
> "className" in
> the ObjectConfiguration.

see above.
> 
>>> Strictly speaking, __CLASS__ should be $fullQualifiedClassName - but
>>> maybe we find a better name?
>>
>> There is also a name missing for a part of the namespace. First I had in
>> mind "component", but it's reserved for a subpackage.
>>
>> e.g. $class = F3\MyPackage\SubPackage\MyClass
>> foreach (explode('\\', $class) AS ??????) {}
>> Any ideas?
>>
>>
>> Annotation:
>> Sticing closer to PHP I had in mind
>> with "directory" as "absolutePath", because of the function is_dir() and
>> the  DirectoryIterator...
> 
> I understand, but still it would weaken consistency in terms of being 
> able to
> guess what a variable contains.
Really?
now: FLOW3_PATH_PACKAGES (can be an absolute path or just the part 
without the root-part to your installation)
alternative1: FLOW3_DIRECTORY_PACKAGES
alternative2: FLOW3_ABSOLUTE_PATH_PACKAGES

Perhaps, I do little bit to much hair-splitting. But easier to change ;)

Is there already a decision about the shorter filenames for classes. 
Refactoring gets much more easier, if you just have to change the 
namespace and not the filename.

Cheers,
Malte


More information about the TYPO3-project-5_0-general mailing list