> On Dec 2, 2015, at 01:59, nyamsprod <
nyam...@gmail.com> wrote:
>
> Hi all!
>
> I have a question regarding the PayloadStatus class. If I understand it correctly, the purpose of the class is to give some basic Payload Status.
Correct. It's a generic list of statuses that are likely to apply to many different Domain situations.
> I wanted to know why you choose to implements those constants on a class rather than on a interface ?
It was previously on an interface, but there was some discussion as to whether that was appropriate. The final "convincer" for me was this article <
https://en.wikipedia.org/wiki/Constant_interface> where it says:
> constants are very often merely an implementation detail, and the interfaces implemented by a class are part of its exported API, this practice amounts to putting implementations details into the API, which was considered inappropriate
Granted, that article is about interfaces of *only* constants, but I think the principle applies when interface methods are present as well.
You can see the extended conversations at ...
- <
https://github.com/auraphp/Aura.Payload_Interface/pull/2>
- <
https://github.com/auraphp/Aura.Payload_Interface/pull/3>
... and note that there was a lot of back-and-forth trying to determine "the right thing."
> But making PayloadStatus an interface disallow any extended class to override the predefined constant values, something which I think would allow for a better usage of the PayloadStatus. Thoughts ?
Overriding the predefined constant values in a domain-specific Payload is *exactly* something we want to allow for. Indeed, one should seriously consider using Domain-specific statuses that more accurately reflect the specific Domain.
Hope that helps explain the reasoning.
--
Paul M. Jones
pmjo...@gmail.com
http://paul-m-jones.com
Modernizing Legacy Applications in PHP
https://leanpub.com/mlaphp
Solving the N+1 Problem in PHP
https://leanpub.com/sn1php