Jonathan Jacky, Margus Veanes, Colin Campbell, Wolfram Schulte
"Model-Based Software Testing and Analysis with C#"
Clients may join and leave the session at any time. If the model of the server state uses a set to keep track of active clients, then the order in which clients arrive will not matter. This is a useful abstraction, especially if no operations of the system depend on the order of client entry. static Set clients = Set.EmptySet; [Action] static void AddClient(string client) { clients = clients.Add(client); } 160 Modeling Systems with Structured State [Action] static void RemoveClient(string client) { clients = clients.Remove(client); } This model program shows the basic operation of sets. The expression Set. EmptySet is a way to denote the empty set of strings. This is analogous to the expression string.Empty provided by the .NET framework that returns the empty string. We say ???the??? empty string because all empty strings are equal.4 It is useful to think that there is just one empty string value, just as there is only one value for 0 or 1. Similarly, there is just one empty set of strings. We should point out that in the set implementation provided by NModel, the values Set.EmptySet and Set.EmptySet are not equal. You can think of each set as having a subscript based on the type parameter inside the angle brackets. This is true even for subtypes: values of type Set