I had this discussion with some people from room 11. The general opinion to 
me seem to be *not* to use the interface suffix, so I started looking at 
why. I'm all in favor for noise reduction in my code, but couldn't really 
see any solution to the conflicting name conventions I faced. Someone 
pointed out to me that you would place implementations in a different 
namespace or sub space. But this generated some strange names such as:

```
use Foo\Bar;
use Foo\Bar\Bar as BarBar;
```

IMO, this is worse then the suffixed interface.
Lets put that into context:


```
use Foo\Cache;
use Foo\Cache\Cache as FooCache;
```

And if you like to make it even worse, what if the namespace is `Psr\Cache`:

```
use Psr\Cache\Cache;
use Psr\Cache\Cache\Cache as PsrCache;
```

...this makes no sense to me, what is what here? and why require an alias?
I understand if you don't develop modular and that then the implementations 
can go in a sub space, such as:

```
use Psr\Cache;
use Psr\Cache\Cache as PsrCache;
```

But sense we like components and modules that needs to be distributed as 
such, then better semantics IMO would be:

```
use Cache\Cache;
use Cache\RedisCache;
use Cache\MemoryCache;
use Cache\FileCache;
```

...implementations should define how they are implemented. When I later 
declare a dependency, I'm declaring that my class is dependent on a Cache 
instance, the interface suffix is redundant.

On a different note, if we are discussing to remove the `Interface` suffix, 
then included in the discussion should also be `Trait` suffixes and 
`Abstract` prefixes as mentioned before. Maybe it can be considered best 
discussed in different threads? In that case, please correct me, but I 
would say that it's the same category and the same arguments.

TL;DR

- Suffixes like `Interface` adds redundant noise to the code.
- Using the suffix makes it more comfortable to create an implementation 
that is not using a naming convention that declares it's implementation 
from a semantic perspective (eg. implementing a CacheInterface into a class 
named Cache)

> My impression is that the majority of member projects use the Interface 
suffix.

The argument that "this is the way we always have done it" is not a good 
argument IMO, evolving implies change. It's an interesting phenomenon 
though: https://www.youtube.com/watch?v=C9ySOuJ83Ww

-- 
You received this message because you are subscribed to the Google Groups "PHP 
Framework Interoperability Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/php-fig/231ce4ae-df4a-47c6-b8c5-17dd33003c14%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to