Is an interface supposed to have the same members on all objects? Or is it OK for different objects to have different interfaces with the same name?

有帮助吗?

解决方案

It won't technically break anything to have interfaces of the same name do different things in different objects. BUT, for the sake of clarity, if you have two objects and they both have an interface with the same name, it would make sense if both of those interfaces were the same.

Kind of like how all objects (as far as I know) have an interface named org.freedesktop.DBus.Introspectable and those interfaces all do the same thing regardless of which object they are contained in.

There is really nothing to be gained by doing it the way you're asking. It only adds confusion if you or anybody has to remember that my-interface behaves one way in object-A and behaves differently object-B. I'd give the interfaces names describing what they do. You'll be glad you did.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top