Allows business rules to be recombined by chaining the business rules together using boolean logic. The pattern is frequently used in the context of domain-driven design.
Questions tagged [specification-pattern]
114 questions
139
votes
5 answers
LINQ to Entities does not recognize the method
I'm getting the following error when trying to do a linq query:
LINQ to Entities does not recognize the method 'Boolean
IsCharityMatching(System.String, System.String)' method, and this
method cannot be translated into a store expression.
I've…

annelie
- 2,569
- 6
- 25
- 39
96
votes
4 answers
Well designed query commands and/or specifications
I've been searching for quite some time for a good solution to the problems presented by the typical Repository pattern (growing list of methods for specialized queries, etc.. see: http://ayende.com/blog/3955/repository-is-the-new-singleton).
I…

Erik Funkenbusch
- 92,674
- 28
- 195
- 291
36
votes
2 answers
Regarding Promises/A+ Specification, what is the difference between the terms "thenable" and "promise"?
I am checking out the "Promises/A+" Specification, but could not understand the following things:
On Section 1. Terminology,
1.1. "promise” is an object or function with a then method whose behavior conforms to this specification.
1.2. “thenable” is…

Microtribute
- 962
- 10
- 24
25
votes
5 answers
Specification Pattern Example
After reading a series of blogs (here and here) by Chris Missal from LosTechies.com on the Specification Pattern I am am really interested in finding more complete examples. Does anyone know where I could find a more fleshed out example or perhaps…

Kane
- 16,471
- 11
- 61
- 86
14
votes
4 answers
Is Specification Pattern Pointless?
I'm just wondering if Specification pattern is pointless, given following example:
Say you want to check if a Customer has enough balance in his/her account, you would create a specification something like:
new…

Henry Aung
- 632
- 1
- 7
- 15
9
votes
2 answers
In which layer should Specification Pattern objects be "new'ed up"?
So, I've looked at some posts about the Specification Pattern here, and haven't found an answer to this one yet.
My question is, in an n-layered architecture, where exactly should me Specifications get "newed" up?
I could put them in my Service…

Michael McCarthy
- 1,502
- 3
- 18
- 45
8
votes
1 answer
Is it ok to call specifications from an aggregate factory for validation, or does that validation call belong in a unit test (DDD)?
I have created a factory and a set of specifications to create and validate an aggregate root. Currently I have some tests for the factory that call the specifications on the product of the factory, but I'm wondering if that's enough. It might be…

Mark Rogers
- 96,497
- 18
- 85
- 138
8
votes
1 answer
Specification pattern with entity framework and using orderby and skip/take
I have picked up a project that uses the specification pattern, a pattern I have not used before, and I had to go and research the pattern. I have noticed it doesn't have OrderBy and Skip/Take functionality, and I can't find anywhere that shows how…

eyeballpaul
- 1,725
- 2
- 25
- 39
7
votes
1 answer
Use QueryHint when using JpaSpecificationExecutor
I use spring data and the JpaSpecificationExecutor::findAll method to fetch my models. How I could use query hints when calling this method?
The above source code works fine but I can't set QueryHint for my JPA provider (in my case…

Georgios Syngouroglou
- 18,813
- 9
- 90
- 92
7
votes
3 answers
Specification pattern async
I'm trying to apply Specification pattern to my validation logic. But I have some problems with async validation.
Let's say I have an entity AddRequest (has 2 string property FileName and Content) that need to be validated.
I need to create 3…

Darkside
- 470
- 3
- 20
7
votes
2 answers
Comparison of Specification Pattern, Func Predicates and Pipes & Filters
I'm doing some R&D work, and as such am exploring design patterns. I have recently been reading up on the Specification pattern and was referred to this great article.
I was intrigued by the simplicity and cleanliness of the code, but i started to…

RPM1984
- 72,246
- 58
- 225
- 350
7
votes
4 answers
Is the Specification Pattern obsolete when you can use Dynamic LINQ?
Wikipedia states that the Specification Pattern is where business logic can be recombined by chaining the business logic together using boolean logic. With respect to selecting filtering objects from lists or collections it seems to me that Dynamic…

David Robbins
- 9,996
- 7
- 51
- 82
7
votes
2 answers
Serialize specification pattern to database
OK, we have to calculate eligibility and rates for insanely complicated insurance enrollment data. Policies can be available based on age, employment characteristics, shoe size, etc. People born before 1962 may be excluded except when they live in…

Code Silverback
- 3,204
- 5
- 32
- 39
6
votes
4 answers
Linq: how to use specifications against associated objects
I'm using specifications in this kind of form:
public static Expression> IsSuperhero
{
get
{
return x => x.CanFly && x.CanShootLasersFromEyes;
}
}
Now I can use this specification in the form:
var superHeroes =…

David
- 15,750
- 22
- 90
- 150
6
votes
3 answers
Specification pattern vs Extension method?
I am trying to grasp specification pattern and i get confused a little about it. I really couldn't found it helpful for my specific requirements. I want to know that what is problem if i prefer extension methods for my complex spesifications? For…

Freshblood
- 6,285
- 10
- 59
- 96