[TYPO3-50-general] File name conventions for classes and interfaces

Ingo Renner typo3 at ingo-renner.com
Tue Dec 12 02:58:35 CET 2006

Robert Lemke wrote:

Hi Robert,

> Let's say we have an interface which describes how a "Greeter" class 
> should look like, then we call the interface "Greeter". One 
> implementation of a greeter could be the "HelloWorldGreeter". An 
> alternative implementation would be the "HelloMartinGreeter". Both are 
> greeters and therefore implement the "Greeter" interface.

IMO you can't do this when sticking to OOA/D principals because you need

* some interface (I actually do prefer the I-prefix)
* then you might want to have a very general implementation "Greeter"
* HelloWorldGreeter would extend Greeter and so on

so to have the very general Greeter class you can't use its name for the 
interface and thus have to come up with a different name.

Another advantage of the I-prefix would also be that you automatically 
have all the interfaces together when ordering the files by alphabet...

And again, it is a well established and common practice in f.e. Java and 
C#, and Visual Basic

> Another example: An interface defines the API for a Template Engine, it 
> is therefore called "TemplateEngine". Now we have three implementations:
>   - SmartyTemplateEngine (implements TemplateEngine)
>   - TemplaVoilaTemplateEngine (implements TemplateEngine)
>   - ClassicTemplateEngine (implements TemplateEngine)

This also leads to the same problem, what if you need a very general 
TemplateEngine class, maybe an abstract class?

> Someone wants to enhance the ClassicTemplateEngine by adding the 

"ClassicTemplateEngine" is considered a kind of bad naming in OOA/D,
in this case I would tend to think of TYPO3 4.x's tempalting engine, 
just call it what it is when it is a general templating engine: 

> The question you should always be able to ask is: "Is [Class name] a 
> [Interface name]?" ("Is SmartyTemplateEngine a TemplateEngine?").

Well, as the name SmartyTemplateEngine suggests that it is of the type 
TemplateEngine it would also imply that it implements ITemplateEngine.

> Sometimes you might even want to use interfaces just because you want to 
> be able to ask the previous question - the interface doesn't 
> neccessarily add any new methods. These interfaces are then called 
> "marker interfaces" because the mark your implementation.
> You see what I mean?

I don't understand your last point.
Anyway in general I would suggest to stick with (or copy from) naming 
conventions that have been in place for years - usually for a reason.

greetings from Platteville

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