-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
RFC: Primary namespace: ActiveModel::Serializer, ActiveModel::Serializers, vs. ActiveModelSerializers #1310
Conversation
|
||
|Gem name | Require statement | Main class or module | | ||
|--------------------------|----------------------------|--------------------------| | ||
| ActiveModel::Serializers | `active_model/serializers` | ActiveModel::Serializers | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
major 👎 this. will. cause. pain. Plus, we all agree, I think, that serializers has got to go as the main namespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bf4 When you get a second, could you expand on the kind of pain this will cause?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bf4 when you say "serializers" what is the namespace? It is ActiveModel::Serializers
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re namespacing see #1310 (comment) @beauby re: pain... it's so obvious to me and all the work we've done together that I'm having a hard time thinking of an answer. Like using classes as namespaces is buggy, like how not everything is a Serializer, like how Serializers don't serialize and is generally a bad name, like how it's not even the core concept of the library anymore... does that mean anything? Does the naming comparison in the other comment help?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In any event, I'm very strongly against changing the name of the library to ActiveModel::Serializer unless someone can make a convincing argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even with the pain I think this is a good time to do that, since the AMS does not reach 1.0, if we will follow Semantic Version it is the right time to break things.
breaking things in pre-1.0 is pretty consistent with semver, unless I misunderstand you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can always deprecate in 0.11, for example and remove the aliases to the old namespace in 0.12 (or 1.0 -- not sure what the release schedule looks like)
It's pretty easy to alias classes :-\
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@NullVoxPopuli @bf4 I agree with both of you about the semver, that if we will change the namespace we are in a good place and time to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bf4 about the name I want change to ActiveModel::Serializers the argument is to follow the Rubygems recomendation and with that keep all the AMS code into a single namespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bf4 @NullVoxPopuli @beauby thanks a lot for your time and attention at this discussion ❤️
So what are the pros and cons about using |
@beauby I think the trade-offs are only about preference about the name in this case. I vote on
The expected gem name, in the gemspec is
All these change are related only with the code, keeping the Rubygems the same way. Active Model for example follow the same idea the gem name on gemspec is
As you can see we do not require |
👍 |
I think we are reaching a common sense here, as we can see at this comment.
If I was wrong please clarify here. @bf4 after the latest discussions, what is your opinion about this? |
@maurogeorge wrote:
This logic is backwards. The gem name is ActiveModelSerializers and the file in lib is active_model_serializers.rb containing the namespace ActiveModelSerializers. The RubyGem convention is for a gem and lib file of those names to put the core library functionality in lib/active_model_serializers (except for some rails engine-related conventions). The initial name of the class in Rails was ActiveModel::Serializers -> ActiveModel::Serializer and the gem was originally named by @steveklabnik as ActiveModelSerializers, then renamed to ActiveModel::Serializer, then referred to as ActiveModel::Serializers, though the gem name didn't change, and recently we started thinking about what the name of the gem should be Now, Rails has ActiveModel::Serializers::JSON and ActiveModel::Serialization all of which makes me think we're better off taking advantage of the gem already having a different name and prefer to use it. For example, what would you call ActiveModelSerializers::Model? ActiveModel::Serializer::Model? (Not to mention that using a class as a namespace causes load-order issues). ref my thoughts on naming and their reasons #1310 (comment) cc @kurko @joaomdmoura @bolshakov @bacarini @mateomurphy @guilleiguaran @spastorino @josh |
I like the idea of following rubygems naming convention. But I think it would be better to have namespace not related to the rails internals. |
@bf4 the logic I followed about the name About the name I wrote about it on the RFC at the motivation section Using a class as a namespace be a bad idea, I agree, this not proposed on this RFC. Thanks to mention and bring more people to the discussion. Let's wait for more feedback and different vision around this. |
|
@bf4 what you mean with whole story? I try expose my points on the RFC and with the comments, I think the more clarifying are 1 and 2. Renaming |
Yeah, activemodel::serializer shouldn't be a class, and when it's not a class, I think it solves the problem, and there isn't anything left to discuss aside from personal preference. :-\ I'm very in favor of the |
I think it's also important, if the direction is to get adopted by rails officially -- which I think would be a huge benefit, esp for rails-api apps. |
You didn't discuss the 'adapters'
The two are intertwined. And if I thought it were a matter of personal preference, I wouldn't bring it up. This is about 1) lessening complexity 2) shrinking the hierarchy 3) future-proofing against namespace collisions between this lib and rails, both of which would build on a second level namespace they own. It would be the only part of rails that doesn't have its own namespace 4) making things more consistent 5) admitting that ActiveModel::Serializer is no longer a good class name for what AMS does, nor is it a good primary namespace 6) deciding to what extent we want to focus on the name 'Serializer' given that the term has narrowed in scope and changed in meaning since it was first used. I included examples of this in the notes for each name #1310 (comment) |
The only possible issue with |
@bf4 thanks for clarifying the question. About adapter today they live in something like
As you can see the idea still the same even if this a adapter or other class/namespace. |
@maurogeorge ok, so you still see the Adapter being inside the Serializer namespace? That doesn't fix anything. It just makes the namespace one level deeper for everything and ties the library to a namespace that this library was removed from |
@bf4 no. The adapter at the end will be in IMO this fixes the 3 different namespaces we use today. |
Ok, @maurogeorge so, do we totally agree on everything in #1310 (comment) except for whether we use ActiveModelSerializers or ActiveModel::Serializers for the primary namespace and gem name? For me, how we intend to use it is part of which one to use. (Besides whether or not we should change the gem name.) If we change the gem name to |
@bf4 I do not totally agree with #1310 (comment) since in this comment the classes are defined on 2 namespaces Yes we can |
Should we try to move this discussion to a Google Doc? It might help organize it better |
I don't think change tools here will solve anything. This PR was created 2 weeks ago, one week ago was called more people to the discussion. I think we can try define what the way we will follow here. I think actually we have the following opinions about the namespace ActiveModel::SerializersActiveModelSerializersIf I was wrong please clarify here. How can we proceed based on that? Thanks for the feedback guys |
I think it makes sense to model after rails' ActiveModel::Serializers I don't remember if it was answered or what the answer was, but I think as long as we keep the gem name, we'll be fine. (I think we could keep the gem name, |
@bf4 thanks ❤️ In fact, when I wrote about that we have the About the content I will update when I work on the project again, probably after the |
[ci skip] Update the RFC adding info from discussion [ci skip]
@bf4 @beauby @NullVoxPopuli guys, sorry for the delay. I updated the RFC following the #1310 (comment) This is ok for you? Thanks |
Reading on my phone, looks good. Did you see the prehistory I added to the changelog? Ams was a reverted rails pr that was supposed to incubate outside of rails, but never got pulled back in, hence tight namespace coupling |
@bf4 cool, it is something that need to be made before the merge? Thanks |
@@ -0,0 +1,105 @@ | |||
- Start Date: (2015-10-29) | |||
- RFC PR: (leave this empty) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be filled int now, right?
@bf4 Thanks for the review. |
| `ActiveModelSerializers.logger` | `ActiveModelSerializers.logger` || | ||
| `ActiveModelSerializers::Model` | `ActiveModelSerializers::Model` || | ||
| `ActiveModel::SerializableResource` | `ActiveModelSerializers::SerializableResource` || | ||
| `ActiveModel::Serializer` | `ActiveModelSerializers::Serializer` | The name can be discussed in a pull requst, we can rename this to `Resource` [for example following this idea](https://github.com/rails-api/active_model_serializers/pull/1301/files#r42963185) more info about naming in the next section| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in a future pull request. For example, we can rename this to 'Resource'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bf4 updated, please take a look when you have some time.
After some internal discussion was decided to use the ActiveModelSerializers namespace. This patch update the content following this idea. Ref: https://github.com/rails-api/active_model_serializers/pull/1310/files#r45947587 https://github.com/rails-api/active_model_serializers/pull/1310/files#r47144210
@rails-api/ams LGTM. ok to merge? |
RFC: Primary namespace: ActiveModel::Serializer, ActiveModel::Serializers, vs. ActiveModelSerializers
Merged. Enough time passed without objection |
Thanks for the merge ❤️ |
Rendered.
Following the #1298 (comment) create a RFC about namespace.
I created the RFC based on the Ember RFCs.
Thanks for the feedback ❤️