Well, is/has is a convention. In Ruby it is common to use "question mark" instead.
But, more importantly, I would not use an imperative verb to name this boolean variable.
Imperative would more appropriate for methods (or functions) that have side effects. In this case, you are using the variable to store the result of a computation.
Striving to become a master Go/Cloud developer; Father ๐จโ๐งโ๐ฆ; ๐ค/((Full Stack Web|Unity3D) + Developer)/g; Science supporter ๐ฉโ๐ฌ; https://coder.today
Howโs it going, I'm a Adam, a Full-Stack Engineer, actively searching for work. I'm all about JavaScript. And Frontend but don't let that fool you - I've also got some serious Backend skills.
Location
City of Bath, UK ๐ฌ๐ง
Education
10 plus years* active enterprise development experience and a Fine art degree ๐จ
Howโs it going, I'm a Adam, a Full-Stack Engineer, actively searching for work. I'm all about JavaScript. And Frontend but don't let that fool you - I've also got some serious Backend skills.
Location
City of Bath, UK ๐ฌ๐ง
Education
10 plus years* active enterprise development experience and a Fine art degree ๐จ
Exactly, prettiest is perfect. One semi colon and a constant away from perfection and we can close this thread. Haha sorry I know this isn't a peer review, old habits and all that.
If you want to make your code even more beautiful:
would be:
(PHP is not my first language, so bear with me if there are missing brakets somewhere)
Good call! Iโve seen several recommendations for using is/has in Boolean variable names.
Well,
is
/has
is a convention. In Ruby it is common to use "question mark" instead.But, more importantly, I would not use an imperative verb to name this boolean variable.
Imperative would more appropriate for methods (or functions) that have side effects. In this case, you are using the variable to store the result of a computation.
This will not work in a real project, most likely you will have to provide a message on why exactly the invalidation failed.
One liners are always on my radar on "smelly code", they usually lead to nasty problems.
Magic number
I said, "more beautiful", not "perfect" :P
Exactly, prettiest is perfect. One semi colon and a constant away from perfection and we can close this thread. Haha sorry I know this isn't a peer review, old habits and all that.
Ah, yes! Semi colons... that thing. xD