Pat Helland has been talking about data inside the service versus data outside the service since at least 2005. I realised back then when I read his paper that the way to model “data inside the service” in C# was to use value types (structs) which could enforce the format and range of its data in the constructor. In this way you could have a value type, say EmailAddress, which had a single string, an email address, and if you passed an EmailAddress to a function, you know you don’t need to revalidate the data, it’s known safe and “inside the service”. Data outside the service is simply a string until it’s brought inside during the construction of a value type for any given domain. The really neat thing about this is how cheap the value types are, they don’t add any overhead, the EmailAddress example above still has only a single string value, and nothing new or additional needs to be allocated on the heap.
Data inside the service and data outside the service
Reply