i'm working through else's codebase , there several lines this:
if (self.abooleanproperty) { self.abooleanproperty = yes; // stuff }
is there any point setting yes
right after checking it? there i'm missing here?
if (self.abooleanproperty) { self.abooleanproperty = yes; // stuff }
in written code, aren't missing , setter line increases billable lines of code 1 no-op.
there 2 reasons, though, done misguided reasons.
as @hotlicks said, there may side effects setter might need triggered. should have been triggered on set unless developer had misguided notion of setting ivar directly everywhere , using above coalesce cost of setting 1 spot. that'd remarkably fragile , silly thing do.
the other reason because, traditionally, objective-c's bool glorified char
. isn't glorified. thus, comparing bool yes
dangerous because yes
has explicit value.
bool mmmmmk = 2; // valid if (mmmmmk == yes) { /* won't execute */ }
sort of when climbing cliff , starts falling, don't yell "bottle", "shoe", "pebble", or "prosthetic limb", yell rock.
so, maybe developer thinking of normalizing affirmative explicit yes. again, quite doubtful and, if case, should raise suspicion quality of rest of codebase.
ouch.
Comments
Post a Comment