[PSR-17] Don't break SRP

166 views
Skip to first unread message

Márk Sági-Kazár

unread,
Aug 9, 2016, 3:20:00 PM8/9/16
to PHP Framework Interoperability Group
Hi all,

Rasmus Schultz had a few comments on the already merged PR: https://github.com/php-fig/fig-standards/pull/759#issuecomment-238637782


To sum up: it's about interface inheritance and the "avoid unnecessary injection" idea. It's basically the same that I already tried to express earlier.


While injecting too much dependencies might be heavy and ugly, the examples from Rasmus clearly shows why it might be necessary in most of the cases and why it provides better flexibility that way.


I would like to propose again to rethink this decision and remove the interface inheritance from the draft.


Regards,
Mark

Iain Cambridge

unread,
Aug 10, 2016, 5:40:51 AM8/10/16
to PHP Framework Interoperability Group
I think an important part of Single Responsibility Principle which is being forgotten is, group things that change for the same reason. 

It's my understanding that you have one responsibility creating a stream, it's suggested that instead of having a single factory that creates multiple kinds of streams, you have multiple different factories. This would mean if I change how a stream is created I would have to then edit multiple factories. This would breach Single Responsibility Principle. Also the fact we only have one responsibility - creating streams would lead us to the fact that we only need one factory. 

If anything it would be a case of having a single highly flexible interface and each of "MemoryStreamFactoryInterface", "CallbackStreamFactoryInterface", "ResourceStreamFactoryInterface", would actually just be classes that implement the factory interface. Since each of them are actually implementations of a factory.

Iain
Reply all
Reply to author
Forward
0 new messages