The Transfer Pattern, by Christophe Addinquy & Frédéric Paulin – EuroPLOP 1998
Abstract Well-designed software separates the domain model from peripheral subsystems (like GUI, persistence or communication infrastructure). However, these subsystems still have to communicate with the domain model. Nevertheless, the domain model should not depend on peripheral subsystems that are susceptible to change. The most common way of having the peripheral subsystems communicate with the domain model is to write dozens of public accessors and mutators for each domain class. We expose a Design Pattern named Transfer that avoids these "bloated" interfaces and isolates the set of specific basic types used in peripheral subsystems of the domain model.
Name Transfer
Example Suppose you have a well-designed model. Now it's time for your application to have an attractive graphic user interface (GUI), with smart dialog boxes. You are strongly committed to follow the well-known principle : the model must not depend on the GUI. To save time, money and sweat, you decide to use a widespread GUI framework. The only remaining thing to do is to connect both sides. At this very moment, you learn two pieces of bad news: First, to show the data, the dialog boxes need to take information out of the model. Since you don't want your model be dependent of the user interface, you feel forced to use accessors and mutators. Doing so, you break down your design by allowing other model classes to use these public accessors instead of creating true services with high level responsibilities. Second, the framework doesn't come only with it's architecture, it also comes with its own set of elementary types. In order to deal with the framework, you should use this set of elementary types. Your model becomes GUI dependent. Now, you know you must find out a solution to this real problem of connection.
Problem The core question answered by Transfer Pattern is "how do you connect peripheral subsystems (for instance the GUI) with the model to ensure data transfer ?".
Context You are designing a software with a user interface using a framework.
Forces • We need to transfer data from the model to the GUI or to other peripheral subsystem ... But we want to avoid creation of public accessors and mutators on model classes. Resisting use of public accessors is a key to force the designers to create a high level responsibilities services. The domain model is the system core and must be preserved. • The framework incites us to use its elementary types ... But we don't want these types to invade our domain model because we want to be able to change of GUI framework or to redesign the GUI with no consequences on the domain model. More over, we want to create our own elementary classes, in order to handle business concepts easily. These classes are used as simple types, such a attributes types or local variables types. In so far as these concrete data types are very specific to a domain, GUI frameworks can't deal with them. • We want an efficient mechanism to transfer data between both sides, especially regarding the number of copy involved ... But we want to limit the coupling between both sides.
Solution Create a set of Transfer classes between the domain model and the subsystem. Each domain class to be represented in the subsystem owns its Transfer class to store and transmit selected data, like the Memento pattern does. The external interfaces of these Memento-like classes are in conformity with basic types used by the domain model. Derive the concerned domain classes from an Editable interface which defines two methods:
1 / 11