All of the tools accept any
number of model programs; they form the product of all of them. No special coding
is needed to prepare model programs for composition (no attributes, etc.). Any two
(or more) model programs can be composed (although the product is not always
useful, of course).
The product of two or more model programs has all the state variables and all
the actions of each of the composed programs. The key idea in composition is that
122 Structuring Model Programs with Features and Composition
namespace ClientServer
{
...
static class ClientServer
{
// State variables, methods used by all features
...
[Action]
static void ServerSend(double datum) // No [Domain], use features instead
...
}
[Feature]
static class TemperatureX2
{
readonly static Set
Temperatures = new Set(99.9, 100.0);
[Action]
static void ServerSend([Domain("Temperatures")] double datum) {}
}
[Feature]
static class TemperatureX4
{
readonly static Set Temperatures =
new Set(98.8, 99.9, 100.0, 101.1);
[Action]
static void ServerSend([Domain("Temperatures")] double datum) {}
}
// Factory class, factory methods select features with different domains
public static class Factory
{
public static ModelProgram CreateWithTemperatureX2()
{
return new LibraryModelProgram(typeof(Factory).Assembly,
"ClientServer",
new Set("TemperatureX2"));
}
public static ModelProgram CreateWithTemperatureX4()
{
.
Pages:
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184