-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Violating Interface Segregation Principle #39
Comments
That is an interesting thought. It is good to discuss such things now. 👍 ATM we got two specs using
I can't come up with a use case where a Specification _need_ that the But let's think of some implications of this... This means that it is always the class that calling |
@Nyholm thanks for reference, yep, that make sense and I'm keen to deliver this change, just need to find some spare time (travelling this weekend again so maybe in a plane or so :) ). |
Awesome @cakper! |
Hello,
PR #35 and question asked by @Nyholm forced me to think about design of our library and I have some thoughts on it:
Comparison
andLogic
namespaces implement onlySpecification::match
but notSpecification::modifyQuery
Query
namespaces implementSpecification::match
others implementSpecification::modifyQuery
but never bothLogicX
logical operations on Specifications that only implement match - example:LogicOr(AsArray, Cache)
will not take any sensible effectSpecification::modifyQuery
are logical And's, have to be matched otherwise don't make sense$query = $qb->where($specification->match($qb, 'e'))->getQuery(); $specification->modifyQuery($query);
Above thoughts led me to conclusion that we are violating Interface Segregation Principle which states:
So basically we have two different concepts here - one that is a Specification and allows us to build query, the other that I don't have name for that allows to manipulate query result (cache it, hydrate as array etc).
In my opinion we should split these two things into two separate interfaces and allow clients to implement single or both. Also because they look like separate things should be passed to
EntitySpecificationRepository::match
separately so we will need to change it's interface to something likematch(Specification $specification, QueryOption $option)
.That will enable us to write more sensible queries to repository. Example:
EntitySpecificationRepository::match(PowerUserSpecification,StandardCacheOption)
EntitySpecificationRepository::match(PowerUserSpecification)
and get non cached results@Nyholm please let me know what you think. I know it changes lib quite dramatically but because we are in pre release mode I think it's the best moment to discuss such thing.
One remaining issue is way of grouping so-called options together (just highlighting it).
The text was updated successfully, but these errors were encountered: