Pattern use

Pattern use

At first glance there seems nothing at all wrong with the pattern shown in the diagram, where a class in one namespace is specialised by a class with an identical name in another namespace.

However, when DATEX II XML schema mapping rules are applied, to support DATEX II backwards-compatible extension both types acquire an identically-named property (in our example here it would be _fooExtension).

While that is a legal construct in XML Schema, and in programming languages like Java and C#, it is sometimes considered a debatable practice because it could encourage programming errors when the property is manipulated in code. An instance of B::Foo has both a B::Foo::_fooExtension property and an A::Foo::_fooExtension property. Programming language rules determine which is meant when a reference to _fooExtension is made, but programmers have sometimes made mistakes in this situation. The pattern can also cause unexpected code Java generation when using JAXB from DATEX II XML schemas. So we recommend avoiding this modelling pattern entirely – choose a different name for each class in the same inheritance tree.

image30