Last week, I posted some questions about the Domain.Contracts.Specifications namespace in WCHM:
Domain.Contracts.Specifications - Querying with filtering, sorting, pagination
In hindsight, the two questions posted there are different enough to warrant separate discussions, so I'm posting this new message to discussion question 1 in particular:
"1) What's the role of Domain.Contracts.Specifications.ISpecification<T>? What is its relation to Domain.Contracts.Specifications.ILinqSpecification<T>?"
With helpful direction from
Howard via Twitter, I was able to review a lot of material on the Specification pattern in general, and the Linq Repository Specification patter in particular:
Implementing the Specification Pattern via Linq
Nicholas Blumhardt's Blog
Linq, the Specification Pattern and Encapsulation
Fredrik Kalseth's Blog
Implementing ORM-independent Linq queries
Rinat Abdullin's Blog
This ultimately led me to Steven Burman's Blog (
http://www.mostlyclean.com/category/Linq.aspx ), and his linq-specifications project:
From looking at the code, and based on Howard's message to the SharpArch mailing list in April 2009:
LINQ + NHibernate + Specification Pattern
S#arp Architecture Mailing List
it looks as though the WCHM Specification implementation is based largely on the linq-specifications project.
Looking deeper at the WCHM code in Domain.Contracts.Specifications reveals though that there are a number of differences between the implementations, which leads me to the following questions:
* What does the WCHM concrete implementation of ISpecification<T> look like? (I cannot find a concrete implementation of this interface in the codebase)
* Can you post a sample usage of ISpecification<T>? In the WCHM codebase, only the ILinqSpecification<T> (via concrete class QuerySpecification<T>) is used to create specifications. (I cannot find any inheritors of ISpecification<T>
in the codebase).
* The WCHM ILinqSpecification<T> contract is more or less equivalent to the Linq.Specifications ISpecification<T>contract. On the other hand, the WCHM ISpecification<T> contract seems to be a lot different, and has a lot
of other functionality (IsGeneralizationOf, IsSpecialCaseOf, etc) not found in Linq.Specifications. What was the motivation for the differences?
I think a nice juicy code sample would help me out the most here, but as always, any comments/feedback are greatly appreciated.
Based on the contracts, I can see WCHM is doing a lot of smart things with the specification pattern. Thank you again for sharing this with the community. I am learning such a great deal from this!
Best regards, Martin