These "Info" objects maintain only invariants within themselves. Invariants between entities are maintained by the state. This helps to achieve more encapsulated code. This code is pleasant to work with and we know that there will be no side effects. Rules/biz logic can be enforced in this class and they will not be broken by outside or new parties/developers to the code. (ex: if Action is Archived then its current Completion state must never change)
コード例 #1
0
        public void When(StuffPutInInbox e)
        {
            var info = new StuffInfo(e.StuffId, e.StuffDescription);

            // Store the details of this stuff in this dictionary
            StuffInInbox.Add(e.StuffId, info);

            // Now Add StuffId to our Inbox HashSet for easy lookup of our "Stuff"
            Inbox.Add(e.StuffId);
        }