Search the web
Sign In
New User? Sign Up
domaindrivendesign · Domain-Driven Design
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Specification Pattern vs Query Objects   Topic List   < Prev Topic  |  Next Topic >
Reply | Forward < Prev Message  | 
Hello!

For some time I have been thinking on the following two sentence:
"Yet another approach for querying is to use the Specification
pattern" ... "Even those Specification classes could very well spit
out IQuery"

Those are sentences from Jimmy Nilsson's book on DDD.

As much as I like the specification pattern and the possibility to
use it with repositories like this:

Rository r = new Repository();
Specification s = new LongNameSpecification();
User[] users = r.GetBySpec(s);

I have simply no idea, what should I do with the specification object
when it comes to real implementation when using some kind of data
mapper or a plain sql even.
Jimmy Nilsson states that Specification can spit IQuery (some kind of
Query Object). OK. If I had IQuery i can work with it, but how do I
get it? I cannot accept coding the same logic once in the
IsSatisfiedBy method and once to spit IQuery and I have no idea how
to do it otherwise.
Any suggestions?

--
Michal





Wed Feb 7, 2007 8:32 am

michal_talaga
Offline Offline
Send Email Send Email

Forward
< Prev Message  | 
Expand Messages Author Sort by Date

Hello! For some time I have been thinking on the following two sentence: "Yet another approach for querying is to use the Specification pattern" ... "Even...
michal_talaga
Offline Send Email
Feb 7, 2007
8:02 pm

Oh well. Based on the input it seams that noone knows the answer for this question. I just wonder how you guys use the specification pattern if it cannot be...
michal_talaga
Offline Send Email
Mar 5, 2007
8:44 am

Is a query object a specification? Is a textual query representation in some object query language a specification? Those two approaches strike me as the most...
berthooyman
Offline Send Email
Mar 5, 2007
10:02 am

... no Query Object: http://www.martinfowler.com/eaaCatalog/queryObject.html Specification: http://www.martinfowler.com/apsupp/spec.pdf I know how to deal with...
michal_talaga
Offline Send Email
Mar 6, 2007
11:11 pm

I agree. A query object is an interpreter (Gang of Four). Its purpose is to abstract a database or search query. A specification is used to abstract a boolean...
jupitermoon_beam
jupitermoon_...
Offline Send Email
Mar 7, 2007
4:38 pm

... Tim's solution only deals with most simple cases i.e.: field quals value. You can extend it a bit to work with ranges for example. But! This will not be a...
michal_talaga
Offline Send Email
Mar 8, 2007
8:42 am

By saying "I see no way" I meant the Data Mapper scenario ;-) -- Michal...
michal_talaga
Offline Send Email
Mar 8, 2007
8:43 am

... I agree it is difficult hence the existance of the Query object. Eric does mention is his book that even though the purpose of the 4 layer architecture is...
jupitermoon_beam
jupitermoon_...
Offline Send Email
Mar 8, 2007
9:33 am

... That is a good question and I'm glad you have asked it. There is at least one ODB that can handle plain specifications in form of predicates. Its db4o. ...
michal_talaga
Offline Send Email
Mar 8, 2007
4:10 pm

Michal, I use an implementation of the Composite Specification pattern that I wrote <http://blogs.interknowlogy.com/timmccarthy/archive/2007/01/22/10863.asp\ ...
Tim McCarthy
mccarthyis
Offline Send Email
Mar 7, 2007
2:41 am

... I ... I'm the one that asked questions on your blog in the comments under the article on Composite Specification. Unfortunately I still have no...
michal_talaga
Offline Send Email
Mar 7, 2007
2:55 pm

Michal, I'm confronted to same problem than you and actually have no clear answer. As you, I like the idea to give a specification to a repository without...
fabien.bezagu-coframi...
fabien.coframi
Offline Send Email
Mar 7, 2007
3:25 pm

Michal, Yesterday, I just red the chapter about Specification pattern in Eric Evans's book. He discuss the use of specifications against repositories. Here are...
fabien.bezagu-coframi...
fabien.coframi
Offline Send Email
Mar 14, 2007
9:22 am

... the ... unacceptable - reason obvious - slow ... repository unacceptable - poluting domain with sql ... used ... Nilsson) Exactly my question: how to do...
michal_talaga
Offline Send Email
Mar 16, 2007
11:33 am

I used the Hibernate code as instruction material - they use a Criteria object, a Criterion object with subclasses for a wide range of criterion types and an...
berthooyman
Offline Send Email
Mar 16, 2007
12:58 pm

Michal ; RE: #3 Example request. How you do this depends greatly on the technology platform being used to implement the repository. If you are using a DBMS...
James Shaw
j.shaw2
Offline Send Email
Mar 16, 2007
1:59 pm

... this is what I'm trying to ask all the time (although not very clearly I suppose when I look at the answers). The 2-4 points are rather strightforward. ...
michal_talaga
Offline Send Email
Mar 19, 2007
9:19 am

Michal An explicit example of implementation level logic would require a very large document indeed. However, I don't think deep knowledge of the supporting ...
James Shaw
j.shaw2
Offline Send Email
Mar 19, 2007
1:30 pm

... involved. Yes, it is needed. How do you suppose you can parse a compiled method body of something like: bool IsSatisfiedBy(User usr) { return...
michal_talaga
Offline Send Email
Mar 19, 2007
8:38 pm

In general I've found that in many cases Nilsson mentions a lot of things that are very hard to implement, especially using an ORM. It sounds like this is one...
colin.jack
Offline Send Email
Jun 22, 2007
2:23 pm

First, I want to clarify I exposed all the options presented in the book DDD of Eric Evans. So if you found an option is not "compliant" with the specification...
fabien.bezagu-coframi...
fabien.coframi
Offline Send Email
Mar 16, 2007
12:59 pm

... book ... with the ... of ... I think I haven't made my point clear enough. There is nothing wrong with examples you have provided. I just wanted to say 1)...
michal_talaga
Offline Send Email
Mar 19, 2007
9:29 am

Michal, I understand you want some examples of specification implementation. The PDF article from E. Evans and M. Fowler is full of examples. Those are...
Bernard Notarianni
bernard_nota...
Offline Send Email
Mar 19, 2007
12:04 pm

... implementation ... in the ... No. I can write my own specifications in many different languages, including English :-) ... (or C#) ... Or more precisely I...
michal_talaga
Offline Send Email
Mar 19, 2007
8:53 pm

I reply to myself ;-) Maybe what I described in my previous post is not the best way to use the specification pattern. This pattern really make sense in...
Bernard Notarianni
bernard_nota...
Offline Send Email
Mar 20, 2007
7:54 am

... repository ... to ... No offence, but isn't a query object a way of specifying what you want? I.o.w.: the specification of what you want is precisely...
Frans Bouma
fransbouma
Offline Send Email
Mar 20, 2007
9:16 am

Wrong! Actually all the patterns from the original question are described and used all over the place. What I'm trying to find out is how. 1) Repository...
michal_talaga
Offline Send Email
Mar 20, 2007
1:18 pm

... Oh am I? Do you have an example implementation of the specification pattern yet? Why not? ... That contradicts with each other. If you want to know WHY, I...
Frans Bouma
fransbouma
Offline Send Email
Mar 20, 2007
1:48 pm

... specification ... My example: http://tech.groups.yahoo.com/group/domaindrivendesign/message/5127 other examples: ...
michal_talaga
Offline Send Email
Mar 20, 2007
4:27 pm
First  | < Prev  |  Next > Last 
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help