Comments (16)
Hey, @Nyholm sorry I was inactive recently :) Will reply today on the evening :)
from doctrine-specification.
No problem. I knew that you had your events and presentation to prepare.
from doctrine-specification.
I was thinking about it, and I'm not really sure what will be the best approach.
I think if we want to deliver complete library we would need to implement all the other specs, that will also allow to delete, update, select only specific things, partial selecting, grouping, make query distinct etc
It will be bigger thing, but maybe it's worth it to have complete solution? Also an option is to release stable version 1.0 with what we have at the moment, and then work on the things I've mentioned.
from doctrine-specification.
I want to deliver a complete library.
Let's fix #21 and #24 and then release the first version 0.1 Make sure it matures before we release the first stable version 1.0. Sounds all right?
from doctrine-specification.
We also need to make a decision if we are happy with the source structure and the naming of the directories and classes. It is much harder to change after we released a stable version.
Example:
// Is this the folder or class?
use Happyr\Doctrine\Specification\Spec;
class Foo
{
function bar() {
$a = Spec::eq('field', 'value');
$b = new Spec\Equals('field', 'value');
}
}
It might be a problem for some operating system, PHP versions or future PHP versions that use Happyr\Doctrine\Specification\Spec
is be referring both a class and a directory.
from doctrine-specification.
Yeah, I agree with structure and naming. What if we just put all sources under Specification
?
Or maybe group with Specification\Logic
, Specification\Comparison
?
So that we will be able to have generic stuff under main namespace, and also Spec
static helper.
from doctrine-specification.
The problem with grouping is that it leads to many imports...
use Happyr\Doctrine\Specification\Logic\AndX;
use Happyr\Doctrine\Specification\Comparison\Equals;
class Foo
{
function bar() {
$spec = new AndX(new Equals('field', 'value'), new Equals('field2', 'value2'));
}
}
use Happyr\Doctrine\Specification as S;
class Foo
{
function bar() {
$spec = new S\Logic\AndX(new S\Comparison\Equals('field', 'value'), new S\Comparison\Equals('field2', 'value2'));
}
}
I think we should have all Specification under one common namespace.. Like:
use Happyr\Doctrine\Specification\Whatever as S;
class Foo
{
function bar() {
$spec = new S\AndX(new S\Equals('field', 'value'), new S\Equals('field2', 'value2'));
}
}
I do think that the EntitySpecificationRepository should have a different namespace from the Specifications.
from doctrine-specification.
Having all sources under the Happyr\Doctrine\Specification
namespace feels okej,... but weird at the same time. We will probably have 15-20 classes in that namespace soon...
This is how Doctrine does it: https://github.com/doctrine/doctrine2/tree/master/lib/Doctrine/ORM/Query
from doctrine-specification.
At a second thought... I like the grouping. You should use the factory class if you want to reduce your imports.
I agree with @cakper on the following namespaces:
Happyr\Doctrine\Specification
the factory class andEntitySpecificationRepository
.Happyr\Doctrine\Specification\Logic
,Happyr\Doctrine\Specification\Comparison
,Happyr\Doctrine\Specification\SomeForJoinAndLimit
etc...
from doctrine-specification.
Ok, so my proposition is to deal with all remaining tasks before release, think abut it a bit more, and then once everything is done we will be able rename it painlessly :)
from doctrine-specification.
I suggest the following grouping. But where does Join
belong?
Happyr\Doctrine\Specification\Logic
- AndX
- LogicX
- Not
- OrX
Happyr\Doctrine\Specification\Comparison
- Comparison
- Equals
- GreaterOrEqualThan
- GreaterThan
- In (not sure)
- IsNotNull
- IsNull
- LessOrEqualThan
- LessThan
- Like
Happyr\Doctrine\Specification\Query
(Not sure about the name of this namespace)
- AsArray
- Join
- Limit
- OrderBy
Happyr\Doctrine\Specification
- BaseSpecification
- EntitySpecificationRepository
- Spec (Maybe renamed to SpecFactory)
- Specification (Maybe renamed to SpecificationInterface)
Other
- Join
from doctrine-specification.
I think Query
namespace is quite ok - it reads good - S\Query\Join
S\Query\Limit
and so on, so join belongs there.
RE "Specification (Maybe renamed to SpecificationInterface)" I'm not convinced by that. I do not consider adding Interface suffix a best practice, and we actually don't do that on projects. Some reading on it: http://verraes.net/2013/09/sensible-interfaces/
RE "Spec (Maybe renamed to SpecFactory)" I think it's good to have names that contain function of the class and I think too that classes should be easy to use, so because primary goal of this class is to provide convenient way of using Specifications name Spec
is better because it is just a helper class :)
from doctrine-specification.
@cakper, I really value your arguments. 👍 The reson I brought these issues up is because I wanted this discussion. You have convinced me on all the bullets above.
I'll make a PR that closes this issue.
from doctrine-specification.
@Nyholm I was thinking about main namespace - what do you think about shortening it a bit and instead having Happyr\Doctrine\Specification
we will just rename it to Happyr\DoctrineSpecification
.
This one additional level doesn't give us any benefits (just adds complexity to imports), and we are not extending doctrine core either.
from doctrine-specification.
Agreed. I'll update #34
from doctrine-specification.
There @cakper. I've updated the namespace to Happyr\DoctrineSpecification
. I would like to have your input on #34.
from doctrine-specification.
Related Issues (20)
- Add createQueryBuilder() abstract method in EntitySpecificationRepositoryTrait HOT 1
- Remove AbstractJoin::getJoinType() method HOT 1
- [Syntax Error] line 0, col -1: Error: Expected Literal, got end of string. HOT 1
- Mysql substring function bug HOT 1
- Disable Style CI HOT 3
- Release 2.0.0 HOT 1
- Check single entity satisfiability HOT 8
- DATE_ADD() and DATE_SUB() platform functions does not work HOT 1
- TRIM() platform functions does not support options HOT 1
- Best practices and architectural decissions HOT 5
- Use defaultRepositoryClassName instead of the RepositoryFactory HOT 4
- Using subqueries HOT 5
- Always use a unique aliases to prevent cases in which we have auto-joining and reserved keywords as context HOT 4
- Psalm annotations HOT 5
- A bit confused about the proper use of `$context` HOT 2
- Customize JOIN HOT 1
- Auto-joins with dot notation HOT 7
- Symfony 6 HOT 1
- How to set Query::HINT? HOT 2
- Supporting future dependencies HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from doctrine-specification.