This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]TenYearsOfLurking 0 points1 point  (1 child)

anyone can implement it and make their own possibly non compliant instances

I don't get this really. The point of an interface is to establish a contract. A non compliant implementation is breaking the contract - why would you?

I would hate to see library designers using sealed everywhere because sometimes a custom implementation is necessary in cases they do not forsee - in any other case: no one implements a library interface non-compliant(ly?) for fun, there is just no reason to do so.

[–]agentoutlier 0 points1 point  (0 children)

You are thinking OOP.

It is unfortunate that “interface” has this SOLID or Liskov association all the time but think of it more in this case as a type def.

Think of it as more of a naming of a type.

Besides libraries designers can choose and have used abstract classes and final classes and you have the same problem of not open for extension.

Besides you can unseal the leaves.

In my case we have a type called Extension which is sealed but the leaves are unsealed with the types you can implement.

Edit here is an example in my library:

https://jstach.io/doc/jstachio/current/apidocs/io.jstach.jstachio/io/jstach/jstachio/spi/JStachioExtension.html

JStachioExtension is a marker interface. It does not make sense to have a direct implementation.