Table of Contents Previous Next
Logo
Facets and Versioning : 34.4 Versioning with Facets
Copyright © 2003-2009 ZeroC, Inc.

34.4 Versioning with Facets

A negative aspect of all the approaches in Section 34.3 is that they change the type system in intrusive ways. In turn, this forces unacceptable programming contortions on clients. Facets allow you to solve the versioning problem more elegantly because they do not change an existing type system but extend it instead. We already saw this approach in operation on page 1066, where we added date information about a file to our file system application without disturbing any of the existing definitions.
In the most general sense, facets provide a mechanism for implementing multiple interfaces for a single object. The key point is that, to add a new interface to an object, none of the existing definitions have to be touched, so no compatibility issues can arise. More importantly, the decision as to which facet to use is made at run time instead of at compile time. In effect, facets implement a form of late binding and, therefore, are coupled to the type system more loosely than any of the previous approaches.
Used judiciously, facets can handle versioning requirements more elegantly than other mechanisms. Apart from the straight extension of an interface as shown in Section 34.2.1, facets can also be used for more complex changes. For example, if you need to change the parameters of an operation or modify the fields of a structure, you can create a new facet with operations that operate on the changed data types. Quite often, the implementation of a version 2 facet in the server can even re‑use much of the version 1 functionality, by delegating some version 2 operations to a version 1 implementation.
Table of Contents Previous Next
Logo