Jump to content

Bracket Usage


Ninjakreborn

Recommended Posts

I have been programming for awhile. I have always had a specific style, but lately noticing with C++ and other languages it gets easier with another format....let me explain.

 

DO you setup your brackets as below:

function whatever () {
  // stuff
  if (whatever) {
    //whatever 
  }else if {
    // whatever
  }
}

Or:

function whatever ()
{
  if (whatever) 
  {
    //Whatever
  }else if
  {
    //Whatever
  }
}

I have always found the second one ugly, but in most third party systems (and frameworks for that matter) I see the second one.

 

What is your personal style/preference, and why.

Link to comment
Share on other sites

it makes no difference how you set up your style

use the method which you like the best and can read easier.

in your one example I layout like so to show relevance for me, also I separate with comments or symbols if code gets too messed up from constant changes

 

to each his/her own

             function whatever () {
                             // stuff
                                    if (whatever) {
                                     //whatever 
                                          }else if {
                                               // whatever
                                                     }
                                               }

Link to comment
Share on other sites

Good, at least glad to hear someone agrees with me. I have seen so many frameworks use that ackward structure. I have always used the first method, but was curious what other people were using.  I find it easier

to read, easier to write, and all around cleaner. Only reason I started getting curious because now even doing C++ whenever I use a codeblocks automatic project, it always formats in the second method, it's a pain.

Thanks for the feedback. I was curious what other PHPFreaks users were doing as far as format was concerned.

 

Only reason I was curious at all was every framework I have ever seen and their listed "coding practices" always showed the second. Was starting to think I was missing something.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.