Re: [PHP-DEV] [VOTE] UUID

This is only part of a thread. view whole thread
  100396
September 5, 2017 20:04 Fleshgrinder <php@fleshgrinder.com>
--mDhJhOegiHvWe0H53428AuW57HGDSqxU6
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: quoted-printable

On 9/5/2017 9:32 PM, Andreas Heigl wrote:
> I'm well aware of that and perhaps I didn't express myself as clear as = I
> should have. >=20 > Imagine a use-case where a UUID-class is needed. But alongside the > toString, toHex and toBinary there's also the need for a further > function (let's call it toArray). So currently I need to create a > wrapper arround UUID that then needs to implement all the public method= s
> of UUID as well as the new toArray. So it works identically to UUID but=
> it isn't UUID. And I have no way of using my own UUID-Class - as it > doesnt' extend UUID - as replacement for UUID. I'd need to expose the > wrapped UUID-Class to be able to retrieve it whenever some libray > expects a UUID. Perhaps this gist can make it clearer: > https://gist.github.com/heiglandreas/452dae591d071cbdfb78b431cb6597fa >=20 > I'm not saying it's the wrong choice. I for myself would probably not > immediately use it as the ramsey/uuid-package is widely in use, but I > could f.e. think, that that package might start to use the UUID-class > under the hood. And then that would be a case where extending could be > helpful as a \Ramsey\UUID would be an instance of \UUID. >=20 > The alternative would be to implement a UUIDInterface that exposes the > relevant methods and that would be implemented by \UUID itself. >=20 > But that's just my 0.02=E2=82=AC >=20 > Cheers >=20 > Andreas >=20
OK, now I understand it better. I would argue that if we really find something existential that should be added, we should add it to the UUID class itself. See, the problem with allowing extension is that we have a real BC issue. All your arguments are well received and correct, but the open a can of worms that is impossible to close. Keeping it final ensures that this cannot happen, ever. We can continue to refine without breaking anyone. I think it also was Ocramius who released a nice article about "final first", but there are probably many from the Java world. Btw. the interface does not really make sense. Interfaces are for polymorphism, in other words, if there are different implementations of the same thing that should be usable interchangeably. This is definitely not the case with UUIDs, the algorithm is set in stone. Don't forget that you can instantiate any kind of UUID with the `fromBinary` method, so you can easily generate different UUIDs on your own and still use the built-in class; no need for extension. --=20 Richard "Fleshgrinder" Fussenegger --mDhJhOegiHvWe0H53428AuW57HGDSqxU6--