Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 689737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T02:21:48+00:00 2026-05-14T02:21:48+00:00

Like any design pattern the Specification Pattern is a great concept but susceptible to

  • 0

Like any design pattern the Specification Pattern is a great concept but susceptible to overuse by an eager architect/developer.

I am about to commence development on a new application (.NET & C#) and really like the concept of the Specification Pattern and am keen to make full use of it. However before I go in all guns blazing I would be really interested in knowing if anyone could share the pain points that experienced when use the Specification Pattern in developing an application.

Ideally I’m looking to see if others have had issues in

  • Writing unit tests against the specification pattern
  • Deciding which layer the specifications should live in (Repository, Service, Domain, etc)
  • Using it everywhere when a simple if statement would have done the job
  • etc?

Thanks in advance

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T02:21:48+00:00Added an answer on May 14, 2026 at 2:21 am

    As David pointed out in his comment, a lot of what is useful about specification can now be more succinctly achieved with the likes of LINQ.

    Instead of a new specification type, you can create arbitrary specifications on-the-fly:
    GetCustomers().Where(customer => customer.IsActive && customer.City == "Oakland");

    This is not a complete replacement for specification, however, for a couple of reasons:

    1. The sorting/filtering happens in the consuming class after returning all customers. If you are dealing with anything other than in-memory objects, this is sub-optimal (LINQ-to-SQL and the like are exceptions because they compile and optimize queries and execute them on the server/remote side, returning only the desired results).
    2. Your API is wide-open to any query if you expose collections and leave the specification to LINQ queries. If you want to constrain what or how much can be retrieved, you’ll need a set of specifications with which to query.

    There is certainly no need to use it everywhere, and it is very possible that you won’t need it at all; I don’t know your domain or what you’re working on.

    I think the best advice is not to look to use it. You’ll see when it is warranted, most likely when you start writing a class that looks like the first example in the article to which you linked.

    Just keep it in your mental pattern repository so you’ve got if you need it; if you never use it, it only means that you didn’t need it, and that is fine.

    The choice of layer is subject to the nature of the specifications and usage. In many cases they are helpers in support of a service layer, but in some cases they encapsulate domain logic.

    As for unit testing, remember that your specifications are units or contain units. Don’t test a method that accepts a specification with all possible combinations of specification; test the specifications themselves to make sure that they behave as expected, and then you can reuse the same specifications with confidence in many methods and classes.

    Hope that’s a bit helpful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Are there any free tools that implement evidence-based scheduling like Joel talks about ?
Update: Since we usually say, the situation will determine if any Design Pattern is
Like any other hard disk, virtual hard discs (*.vhd) will suffer from fragmentation. So
Is there any IDE (like VS) with drag and drop support for building python
Is there any function like php's mb_convert_encoding which can convert an encoding to another?
I would like to intercept any URL which the user enters in their browser
Following this question: Good crash reporting library in c# Is there any library like
It's been a while since I've had to do any HTML-like code in Vim
Is there any reason something like this would not work? This is the logic
Is there any RDBMS that implements something like SELECT * EXCEPT ? What I'm

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.