Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

How would you space this code block?

Name: Anonymous 2011-04-28 15:54


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();
}

Name: Anonymous 2011-04-28 16:35

I would remove the Latin placeholder comments.

I would never use C++ style comments, they're considered harmful.

I would move the or's at the end of each line as opposed to the beginning.

Name: Anonymous 2011-04-28 16:35

Name: Anonymous 2011-04-28 17:29


VICTORY TO THE FARTISTS!

Name: Anonymous 2011-04-28 17:34


VICTORY TO THE FARTISTS!

Name: Anonymous 2011-04-28 17:36


VICTORY TO THE FARTISTS!

Name: Anonymous 2011-04-28 17:42


VICTORY TO THE FARTISTS!

Name: Anonymous 2011-04-28 17:53

What now, bitch?


int Foo(bool isBar) {
    if (isFoo) {
        bar();
        return 1; }
    else {
        return 0; }}

Name: Anonymous 2011-04-28 18:36


if ( (pokemon != getSelectedPokemon())
    || (pokemon->health != 0)
    || (pokemon->health < MIN_HEALTH)
    || (pokemon->health >= MAX_HEALTH) ) {
    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.


inline bool isNotSelected(Pokemon* pokemon) {
     return (pokemon != getSelectedPokemon());
}

inline bool isDead(Pokemon* pokemon) {
    return (pokemon->health < MIN_HEALTH) || (pokemon->health >= MAX_HEALTH);
}

...

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.

Name: Anonymous 2011-04-28 19:20


VICTORY TO THE FARTISTS!

Name: Anonymous 2011-04-28 19:28

>>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).

Name: Anonymous 2011-04-28 19:33

>>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: Anonymous 2011-04-28 19:34

But whom will save Xarn?

Name: Anonymous 2011-04-28 19:51

But whom will save Xarn?

Name: Anonymous 2011-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: Anonymous 2011-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 () ;}

Name: Anonymous 2011-04-29 5:21

>>16
ugly

Name: Anonymous 2011-04-29 5:41

  if ( pokemon != getSelectedPokemon() ||
      !pokemon->health                 ||
       pokemon->health < MIN_HEALTH    ||
       pokemon->health >= MAX_HEALTH     )
    {
      this->remove(pokemon);
      abort();
    }

Name: Anonymous 2011-04-29 5:48

>>18
With comments


  if ( pokemon != getSelectedPokemon() ||  /* Blah Blah */
      !pokemon->health                 ||  /* Blah Blah */
       pokemon->health < MIN_HEALTH    ||  /* Blah Blah */
       pokemon->health >= MAX_HEALTH     ) /* Blah Blah Blah */
    {                                      /* Etc. */
      this->remove(pokemon);
      abort();
    }

Name: Anonymous 2011-04-29 7:30

>>17
define ugly

Name: Anonymous 2011-04-29 7:35

>>17
your mom

Name: Anonymous 2011-04-29 9:35

(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)))

Name: GNU 2011-04-29 10:06

VICTORY TO EVIL STALLMAN

Name: Anonymous 2011-04-29 12:03

>>23
Someones using the Sword of the Fartist for a non fartist agenda.

Name: Anonymous 2011-04-29 12:09

>>24
Shitposts ARE the fartist agenda.

Name: Anonymous 2011-04-29 14:20

>>25
The typographic treatment of code is hardly a superfluous topic.

Name: Anonymous 2011-04-29 14:30

>>26
Reprocess the syntactic tree to correct your output.

Name: BLACK HITLER 2011-04-30 0:44

glory BLACK AFRIKA HEIL NIGGERS. HEIL BLACK AFRIKA. NIG HEIL BLACK HITLER!

Name: BLACK HITLER 2011-04-30 0:44

glory BLACK AFRIKA HEIL NIGGERS. HEIL BLACK AFRIKA. NIG HEIL BLACK HITLER!

Name: Anonymous 2011-04-30 6:22


Don't change these.
Name: Email:
Entire Thread Thread List