When different versions of services exist, different versions of data types are also involved (at least, if the services use structured data types). Dealing with this issue can become a lot more difficult than just dealing with different service versions.
Say, for example, that a new attribute for a Post Office box is added to a service that returns data including an address. That is, the existing address type, which has the following attributes:
String street String zipcode String city
gets this new attribute:
Because older versions of the service use the older address type and newer versions of the service use the newer address type, two different address types are in use in the same runtime environment (see Figure 12-2.
Figure 12-2. Two different versions of an address type
The question is how to deal with this fact. In principle, there are three possible options:
Use different types for typed interfaces.
Use the same types for typed interfaces.
Use generic code so that type differences don't matter.
I will discuss these options now in detail.
When using different types for different versions of a type, you might be tempted to simply apply the same rule I suggested in Trivial Domain-Driven Versioning for naming and distinguishing between the types. However, this situation is more complex, for ...