Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
You don't like me?!?! :) On a serious note, what's the alternative or better way?
-
zshh38489yThen he perhaps must create a new variable called isNotActive which is bad for performance.
-
pardeike2819y@simeg That depends. Most compilers optimize that away. Unless you use a crappy language of course ;-)
-
pneves3329yAnd i'm the only one o doesn't like that because of the "is" and just use "active" instead?
-
pardeike2819y@simeg java, swift, c/c++, JavaScript and many more. Basically anything that gets compiled or turned into bytecode
-
pneves3329y@simeg Thinking about it and maybe you're right. Because I'd some trouble in the past when I want a method to active something and a property to know if it was active. You give me the solution and I'm thinking how dumb I was! 😐
But I'm thinking now that a active() method that gives you the state and change the state when you give it a argument wold be right too, but when performance is a really concern, this was not the best solution. -
ui-guy479yAs a general best practice you should keep all your methods positive and if needed use bang (!) to negate them.
Otherwise you end up with crazy code like this and it takes you 3min just to comprehend it.
if(!isNotDisabled()){
...is it enabled?!?!?
}
people who writes 'if (!isActive){} '
I do not do like you.
undefined
condition if