Why doesn't IAnyMicrosoftInterface(N)
inherit IAnyMicrosoftInterface(N-1)
?
Here you go examples of the opposite:
The IFilterGraph3
interface inherits from IFilterGraph2
. IFilterGraph3
also has these types of members:
Or
The ID2D1Bitmap1
interface inherits from ID2D1Bitmap
. ID2D1Bitmap1
also has these types of members:
Those are two approaches in design of COM interfaces. It can work out both ways. Both ways all new and old methods are accessible through both interfaces (and possibly through new interface only). If you choose to inherit, you basically duplicate all old methods on new interface and one does not need old interface at all. If you choose to not inherit you get the option of redefining certain methods to, for instance, add new parameters and have still everything look well all together.
Can I be sure that if some object supports ISomeInterface5 then it also supports ISomeInterface4?
No. It might be exactly the point that newer implementation does not drag too much of legacy stuff in. Or, designer prefers to reuse older/newer code on the same class in the way that old and new implementation is backed by the same class. Regular COM rules apply here: an object might implement many interfaces; you QueryInterface
to discover them programmatically, and you make assumptions on interface availability using documentation in case it is clearly promised that specific implementation offers multiple interfaces, esp. such as also older version of evolving interface.