Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Pet Peeve

Pet Peeve

Scheduled Pinned Locked Moved The Lounge
tutorialquestion
102 Posts 51 Posters 6 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R rjmoses

    I personally prefer this convention: if ((a cond b) conjunction (c cond d) conjunction // Additional conditions always on separate line (e cond f)) { // Always include opening brace do .... something } // Always closing brace Or } else { // Always closing brace..else..opening brace do .... something else } // Always closing brace The same conventions and principles apply to loops (for, while, etc.) and other conditionals. I strictly avoid NOT using braces under any circumstances. I want to be able to see a complete thought, i.e., a block of code, in one intact, obvious section. These are my thoughts based on years of chasing bugs, modifying other people's code, and having to debug somebody else's problem. Other people are welcome to use their own conventions, but I may not be able to help them efficiently. Just because I can do something doesn't mean I should do it.

    R Offline
    R Offline
    ronchristie
    wrote on last edited by
    #101

    It's interesting that the older the programmer the more concision becomes important. :)

    Ron Christie

    1 Reply Last reply
    0
    • R R Giskard Reventlov

      Why are people so lazy? For example, how hard is it to

      if (condition)
      {
      DoThis();
      }
      else
      {
      DoThat();
      }

      as opposed to:

      if (condition)
      DoThis();
      else
      DoThat();

      Pedants :sigh:

      A Offline
      A Offline
      Al Chak
      wrote on last edited by
      #102

      I have more

      (condition)?DoThis():DoThat();

      DoThese[(condition)]();

      #define CALL_FUNC(__F) Do##__F
      CALL_FUNC(condition);

      do
      {
      if(condition)
      {
      DoThis();
      break;
      }
      } while(DoThat()&&condition);

      <pre lang="cs">
      switch(condition)
      {
      case 1:
      DoThis();
      break;
      default:
      DoThat();
      }

      :laugh:

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups