Questions tagged [specification-pattern]

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.

114 questions
1
vote
1 answer

Elegant way to shape the data when implementing Specification pattern for in-memory collections

Is there any robust, elegant, and/or standard way of implementing the Specification pattern for in-memory collections (IEnumerable, not IQueryable) that includes shaping/projecting the results? Using Func for criteria obviously covers…
Leaky
  • 3,088
  • 2
  • 26
  • 35
1
vote
0 answers

Persisting specifications

I'm building a system where a user can subsribe for items and get periodically notifications for new items. Users should define what items they want by filtering on certain properties. I'm using the specification pattern to filter items. My thought…
alexn
  • 57,867
  • 14
  • 111
  • 145
1
vote
2 answers

How to implement isGeneralizationOf with the composite specification pattern?

I am trying to implement the composite specification pattern, as per the Specifications Document by Fowler and Evans. At first impression, I thought the implementation of isGeneralizationOf would be different for conjunction and disjunction. In…
1
vote
3 answers

C# how to build logical workflow using predicates and action delegates?

Is there a design pattern that can be applied where I can build sophisticated workflows without having to write multiple conditional and nested conditional statements - I think the answer may lie somewhere in employing something like the…
puri
  • 1,829
  • 5
  • 23
  • 42
1
vote
1 answer

repository pattern with specification pattern in java

I am trying to implement the repository pattern to query users and the corresponding settings associated to each user. I am having a repository interface which has the crud operations to be implemented by each and every repository. import…
wandermonk
  • 6,856
  • 6
  • 43
  • 93
1
vote
0 answers

Combine logical expressions while prioritizing expressions

I'm in the process of creating a complex authorization module for a system which will be based on the specification pattern. Access rules are defined as followed: An operationName defines to which operation the rule applies to. A…
plalx
  • 42,889
  • 6
  • 74
  • 90
1
vote
1 answer

.NET Repository pattern generic Query Methodology

I am using Repository pattern and i have a base repository and i use Entity Framework and web api; my question is I want to allow my clients to be able to query any data dynamically; something like query expressions and fetch xml used in Dynamics…
yo2011
  • 971
  • 2
  • 12
  • 38
1
vote
1 answer

Specification pattern using Entity Framework (order by property)

I want to write some API to sort entities on server side (SQLServer) using LINQ2Entities. I have class which contains expression represents sorting field of entity and sorting direction : public class SortOption { public…
1
vote
1 answer

Filtering entities on a version field with JPA Criteria-API

I have an entity with an embedded id which contain an id and version field. @Entity @Table(name = "MyEntity") public class MyEntity { @EmbeddedId private MyEntityEmbeddedId compositeId; @Column private DateTime begin; @Column …
0
votes
0 answers

JPA Specification how do I check if an object satisfy it without query execution in kotlin

How do I implement method to check if an already loaded object satisfy to a Specification? fun isSatisfiedBy(spec: Specification): (TaskJPAEntity) -> Boolean { return { task -> // test it without query execution } }
Serhii Shliakhov
  • 2,631
  • 3
  • 19
  • 37
0
votes
0 answers

Errors in the use of Specification, returns one object out of 2 matching the search criteria

Errors in the use of Specification, returns one object out of 2 matching the search criteria, while builder returns the correct value. springDatabaseItemRepository.findAll(builder.build(), pageable); I'm looking for 3 conditions: 1 of which joins…
0
votes
0 answers

What is the algorithm for checking logical equivalence of specifications?

Consider I have an audience target group defined as: age >= 13 && gender == Gender.Female or as gender == Gender.Female && age >= 13 These are equivalent specifications, which differ slightly in definition. However, specifications can be…
Pavel Voronin
  • 13,503
  • 7
  • 71
  • 137
0
votes
1 answer

Need help understanding The Specification Pattern - Inheritances

I believe that this is more of an inheritency question, but since I am trying to grasp it better by implementing a pattern that uses it, I thought I would ask my question related to get a better grasp. If you use the Specification Pattern, having a…
pghtech
  • 3,642
  • 11
  • 48
  • 73
0
votes
1 answer

Specification pattern with Entity Framework generic repository pattern

Recently I have encountered an article Implement the Query Specification pattern and I am confused about using specification pattern with generic repository. I have already a generic repo like this: public interface IGenericRepository where…
0
votes
0 answers

Make Specification pattern to search any property and condition

I have a clean architecture app, I have a web api, I want to know if it is possible to make a specification where in the [HttpGet] you can set what properties you want to search and the conditions or if I need to create particular…
Nickso
  • 785
  • 1
  • 10
  • 32