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
Model instance isPersisted() and propertyIsBlank() methods #559
Comments
@perdjurner @neokoenig Thoughts? |
Sounds like a good improvement. Maybe we should take this opportunity to review other similar functions? exists() |
To follow up... isClass() and isInstance() are already the opposites of each other so we can remove those from the list. I think we can also remove isGet(), isAjax(), isPost() from the list to review since I think it's rare that you would want to use the oppose of any of those. This leaves us with: exists() |
Interesting idea. This may be a good time to come up with an alias for
Many of those I cannot think of antonyms for, which could be a challenge.
|
Are you avoiding using the word "not" for a specific reason? If not, wouldn't: hasChanged -> hasNotChanged be easier to read than: hasChanged -> hasUnchanged |
Yes, I am. I'd hate to see code that looks like this: <cfscript>
if (!this.hasNotChanged()) {
}
</cfscript> Or even better: <cfif not this.hasNotChanged()>
</cfif> Am I being too pessimistic? |
I do think you are being too pessimistic here. We should provide the best options for creating readable code, and do our best to use it in documentation so developers can pick up on it. In that regard I prefer something.hasNotChanged() over something.hasUnChanged(). |
We need to be careful with double negatives. Good: Not good:
"unChanged" I don't think is a clear term. I'm definitely more of a fan of |
Rails doesn't implement any of these other than the equivalent to what would be our Though I'm glad we took a minute to explore it, I feel like the other ideas are forced. Including the word "Not" in the name probably isn't any easier to parse mentally than the |
isPersisted()
methodisPersisted()
and propertyIsBlank()
methods
isPersisted()
and propertyIsBlank()
methods
API Docs: |
Rails has
#persisted?
, which is the inverse of#new_record?
to help avoid "negative" boolean logic.For example,
if user.persisted?
is easier to process thanif !user.new_record?
orunless user.new_record?
.I propose that we add
isPersisted()
for the same reason.If there are no objections, I'd be glad to implement and document this for CFWheels 2.0.
The text was updated successfully, but these errors were encountered: