if ( pokemon != getSelectedPokemon() // lorem ipsum dolor sit amet
|| !pokemon->health // lorem ipsum dolor sit amet
|| pokemon->health < MIN_HEALTH // lorem ipsum dolor sit amet
|| pokemon->health >= MAX_HEALTH // lorem ipsum dolor sit amet
) {
// lorem ipsum dolor sit amet
this->remove(pokemon);
abort();
}
Like that. Note the removal of comments (comments for fucking everything is retarded and for amateurs). I also removed the explicit use of this when calling remove, fucking redundant. I also added extra parentheses to convey intent with the various conditions. Note that if MIN_HEALTH is always greater than zero, you can get rid of the explicit check to ensure health is not equal to zero.
If you really wanted to clean it up to be well-factored and self-commenting, you could create some private inline member functions.
if (isNotSelected(pokemon) || isDead(pokemon)) {
remove(pokemon);
abort();
}
Note how that really cleans up the code and is much more self-commenting, without the need for actual comments. That's the ENTERPRISE way to factor code.
>>9
I used retarded, unspecific placeholders for extant code (including the numerous comments, which are actually meaningful and relevant in this particular block). The metaphors are misleading because the real code doesn't lend itself to refactoring; I was more curious about /prog/'s formatting preference (I can understand why you would consider and suggest those changes).
>>2 I would move the or's at the end of each line as opposed to the beginning.
But if you remove or shift a line, you might unwittingly introduce a bug; whereas with the or placed on the line preceding the new statement, you have the entire condition contained on the same line.
Name:
Anonymous2011-04-28 19:34
But whom will save Xarn?
Name:
Anonymous2011-04-28 19:51
But whom will save Xarn?
Name:
Anonymous2011-04-29 3:59
how would you space this code block?
'?'~~$o?$i{$n}?$c.=$i{$n}:next:$o~~'!'?$h{$n}?$i{$n}?$c.=
$i{$n}:next:die"! $n":r($u)?$c.=n($u):r($u)?$c.=n($u):'?'
Name:
Anonymous2011-04-29 4:53
if (or (pokemon != getSelectedPokemon () // lorem ipsum dolor sit amet
,! pokemon -> health // lorem ipsum dolor sit amet
,pokemon -> health < MIN_HEALTH // lorem ipsum dolor sit amet
,pokemon -> health >= MAX_HEALTH)) // lorem ipsum dolor sit amet
{// lorem ipsum dolor sit amet
this -> remove (pokemon) ;
abort () ;}
(if (or (!= pokemon (getSelectedPokemon)) ;; lorem ipsum dolor sit amet
(! (-> pokemon health)) ;; lorem ipsum dolor sit amet
(< (-> pokemon health) MIN_HEALTH) ;; lorem ipsum dolor sit amet
(>= (-> pokemon health) MAX_HEALTH)) ;; lorem ipsum dolor sit amet
;; lorem ipsum dolor sit amet
(begin ((-> this remove) pokemon) (abort)))