[TYPO3-50-general] RFC: Short filenames

Nino Martincevic don at zampano.com
Tue Jan 27 12:17:22 CET 2009


Hi Robert,

Robert Lemke wrote:
> I was only referring to the filenames here, the class naming scheme is a
> different topic.

Ah ok, misunderstanding this a bit.

> So the question is: What should be the name of the file containing the
> class \F3\Foo\Bar\Baz ?
> 
>  a) F3_Foo_Bar_Baz.php
>  b) Baz.php

I do it this way:
I have a somewhat dir structure for packages, say Domain\Model\Foo, 
where Foo is an aggregate e.g.

Inside there my files are Foo (for the aggregate/domain objet itself) 
and then stuff like FooBar, FooFactory, FooFighters [:-)], FooSomethingElse

There could also be subdirs, I often have Specification,
then I call them FooCreateSepecification, FooAssignSpecification.

In the ZF naming scheme I'd have to place it in Domain/Model/Foo.php and 
then have a subdir Foo for placing the rest of that aggregate, not good.

All the filenames are named like the classes, so their intention reveals 
both by filename as by class.

Wouldn't be if I call it
/foo/specification/Assign.php and the class also Assign.

That way I can refactor it to another place and they don't lose their 
meaning, even not as only a filename.

So the formula is:
Domain meaning and naming = class and file naming and meaning
So every domain class and its file has its meaning, regardless of its 
location.
Exceptions are generic or vendor classes, everything that's not part of 
the domain. That way I'm not addicted to any vendor naming schemes.

Another important reason:
If I change my underlying framework(s), does my domain changes?
Well if that would be the case, good'night...

And with DI/IoC you can do such beautiful things...

>>>  - doesn't give the full hint on the contents (DefaultController.php ?)
>>
>> Thou who calls a class that way: Fire him!
> 
> Not possible. Open Source Project.

Hehe, then ban him!

> It happens all the time. Take ZF for example:
> 
> Zend/
>   Acl/
>       ...
> 

Yes, but your question was aimimg at solving this issue, wasn't it?
As I said: I'd never have file names like Controller, controller for 
what? Or Interface, interface for what?

IBlogEntry, IFileCopier, IMessageLogger, Blog, BlogComment, 
BlogController ... put them where you want, you could even put them in 
one directory, no problem.
They refer to my domain and its objects, not to anything external.

>> Change your editor.
>> No joke: if a software impedes me at my design work, I throw it our the
>> window and better use a text editor.
> 
> Also no joke: If 99% of the software runs fine, I don't throw it away and
> work with notepad instead. So ...

Hm, apples vs. bulbs?
I did not say that Eclipse sucks. It runs 99% (ok, say 80%...)
But software changes, new versions and IDE's are coming and leaving and 
in a OS project you can't dictate one's editor either.
What if I want to work on my netbook where eclipse doen't run, can't I 
change code or lose my outline?

If many people with different gusto regarding their editor work a 
project it's even more important that the code, the naming scheme and 
the intention works and reveals. Isn't it?

Nino


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