Content deleted Content added
ridiculed pattern even more with C# 6 |
|||
Line 268:
<source lang="csharp">
var InvoiceCollection = Service.GetInvoices();
foreach (
// Invoice methods:
public void SendToCollectionIfNecessary()
{
if (ShouldSendToCollection()) SendToCollection();
}
private bool ShouldSendToCollection() => currentInvoice.OverDue && currentInvoice.NoticeSent && !currentInvoice.InCollection;
</source>This alternative uses foundation concepts of Get-Only Properties, Condition-Logic, and Functions. The key alternative here is Get-Only Properties, which are well-named to maintain the Domain-Driven language, and enable the continued use of the natural && operator, instead of the Specification Pattern's And() function. Furthermore, the creation of a well-named function SendToCollectionIfNecessary is potentially more useful and descriptive, than the previous example (which could also be contained in such a function, except not directly on the object apparently).
|