Happyr / Doctrine-Specification

This library gives you a new way for writing queries. Using the Specification pattern you will get small Specification classes that are highly reusable.
MIT License
445 stars 40 forks source link

A bit confused about the proper use of `$context` #309

Open acelaya opened 3 years ago

acelaya commented 3 years ago

I migrated a couple of months ago to v2 of this library, and the most confusing part was getting my head around the new context concept.

I managed to get it working, thanks to the fact that I have extensive functional and E2E test suites.

However, I find myself in the position of having to apply some changes to the project, due to new requirements, and I'm having a hard time making a proper use of the context in my specifications. Every change I do to fix something, breaks someother use case.

When I did the migration I decided to cut some corners and hardcode some aliases, with the intention to tackle that tech debt later, but it's a bit confusing.

Is there any possibility to have a more extensive documentation that explains how to properly use the context, how it works internally, and what are the implications?

I checked https://github.com/Happyr/Doctrine-Specification/blob/2.x/docs/0-usage.md and https://github.com/Happyr/Doctrine-Specification/blob/2.x/docs/1-creatingSpecs.md, but they don't go into much detail, and assume you know what it is for.

Thanks!

peter-gribanov commented 3 years ago

Yes. You're right. The documentation is poor at revealing the essence of contexts and how they work. We will try to fix this problem. Thank you for your comment.

Have you already read the instructions for upgrading to version 2? The instructions mention the use of contexts with examples.

acelaya commented 3 years ago

Yes, I checked it back then and it definitely helped. But I admit I didn't remember about it. I'll give it another look.

Thanks!