-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Rename ZLayer to ZServiceBuilder #5815
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
Conversation
Bump docusaurus version
IMHO, 'dependency' seems to capture only half (input) side of If I must choose one alternative name to |
@guersam , how about a name like |
Throwing my hat in the game with |
But |
True 😂 I think the profunctor property is not exploited anymore, iirc @adamgfraser told me this wasn't a pattern that was encouraged so much anymore, and I find it has been a challenge to teach layers and the |
Frankly, I often get confused of when to encode the dependency in I think we need to gather the best practices for this first, then upon a deeper understanding we may find better name for |
After a lot of thought, the I've grown to like Why? Because the terminology seems to be consistent:
As part of this, we would change "Module Pattern" to "Service Pattern", thus consolidating a lot of different terms under the "service" umbrella. /cc @khajavi |
@jdegoes In addition, regarding this term consolidation, I propose renaming the This would be consistent with the |
I like it too. Will update accordingly. |
@khajavi I like the direction you are going in renaming |
@jdegoes This is ready for review. |
@adamgfraser One minor question: Should it be |
The |
@jdegoes I wondered about that too. I went with However, thinking about it more I like making it plural because it creates a distinction between operators like Will change. |
Late to the party, I didn't know why I hated so much reading about this change. Thinking about it I figured out that apart from sounding like a a "Java something" that I ran from and came to You took something not great to type and made it worse, I don't know if is better for new people coming to |
@octavz Sorry to hear that! We're always trying to strike the right balance for all users. There are definitely some people who found the concept of layers confusing and it really did only have a meaning within the concept of an "onion pattern" architecture which is great but not everyone knows. As is often the case with naming I don't think there was a perfect solution here. As you can see we went through a variety of alternatives that people proposed and on balance this seemed to be the best alternative. It does exactly what it says, which is build the services your application needs. You are right it is longer but we think conceptual clarity wins out over terseness, especially with features like autocomplete in modern IDEs. One thing that did jump out at me is your statement that this is the second most frequent data type you type. That is very surprising to me. Use cases are definitely going to vary but I find it is typically one of the ones I write least frequently. Anyway, definitely appreciate your perspective and hope that over time with other features in ZIO 2.0 like automatic construction of the dependency graph and a more structured way of defining services we can win you over and make building your application's dependencies as easy as possible. |
I am not complaining I will just adapt, but I am also surprised by your "surprise" :), Unless we are using this completely wrong: You have to type At first sight it might not be a lot but think about the tests, every test will stub and every stub has to become a layer, every test has at least one stub which makes "ZLayer" or variants basically the most used thing in your code. Also if we follow conventions any For a small module:
compare to ZIO usages
Also IDEs for Scala are slower than typing most of the time so they are not big help there, IntelliJ hardly works with ZIO, Metals "almost" works but more times it doesn't than it does. |
Happy this got reverted but for posterity I wanted to share another opinion. |
Resolves #5805.
The
ZLayer
name really only makes sense in terms of the "onion architecture" and representing different "layers" of the onion (e.g. theGithub
service might translate from the lower level domain of HTTP to the higher level domain of the Github API). While this is a very insightful way to view program architecture, it requires you to know this particular concept which is an obstacle to usability and teachability because many people may not.This PR explores instead naming it
ZDeps
for dependencies, a bundle of dependencies that you provide to your application.