braces

This is a discussion on braces within the Tech Board forums, part of the Community Boards category; Originally Posted by John_ Doesn't this come down to the IDE you use to write your code in? Are you ...

  1. #16
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,066
    Quote Originally Posted by John_
    Doesn't this come down to the IDE you use to write your code in?
    Are you trying to say that you're solely dependant on how your IDE indents your code in order to have it indented?

    Try writing C++ in notepad.
    Sent from my iPadŽ

  2. #17
    Distributed Programming beyonddc's Avatar
    Join Date
    Dec 2001
    Location
    Mass
    Posts
    31
    It's really depend on how you want your program to read like.

    In my company, we've coding standards for Java, and C++.

    For Java, we follow your first example, and for C++, we follow your second example.

    There's actually a Sun Microsystem recommanded Java Convention that you can found online.

    The site is Java Convention
    -dc

  3. #18
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    Code:
    int main() {
    
    
    
    
    
    cout << "Hi";
    
    
    
    
    
    
    cout << "Bye";
    
    
    
    
    
    }
    That way you can debug see each line as your scroll down thousands of spaces XD.
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  4. #19
    Registered User
    Join Date
    Jan 2006
    Posts
    63
    Quote Originally Posted by SlyMaelstrom
    Are you trying to say that you're solely dependant on how your IDE indents your code in order to have it indented?

    Try writing C++ in notepad.
    What I meant is that 7stud said they lack indentation, but I was wondering what he meant by it. Like for example if we were writing code in notepad, wouldn't all methods lack indentation unless we added it ourselves.

    Or if he meant using certain methods the IDE wont indent code properly, in which case I was asking if this comes down to just the IDE.

    Basically I was just asking him to clarify what he meant so I can learn from it

  5. #20
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Quote Originally Posted by John_
    Like for example if we were writing code in notepad, wouldn't all methods lack indentation unless we added it ourselves.
    Style is generally added by "ourselves". (At least in the "old days".)

    This might be an example of what was meant.
    Code:
    class myClass
    {
    public:
       void function();
    };
    vs
    Code:
    class myClass {
    
    public:
    void function();
    
    };
    But I used a beatufier and some editing to force it to my preference(s).

    An IDE helps to put things how the programmer chooses (if it's a good one), rather than limiting the programmer to what it chooses. But again, it should be the programmer calling the shots.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  6. #21
    aoeuhtns
    Join Date
    Jul 2005
    Posts
    581
    Quote Originally Posted by swgh
    braces
    See what happens when you mention these on a programming forum? I hope you learned your lesson.

  7. #22
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,066
    Next topic. Square brackets.

    I personally use this method:

    Code:
    int arry[
       3
    ];
    *nyuck nyuck*
    Sent from my iPadŽ

  8. #23
    Registered User
    Join Date
    Nov 2005
    Posts
    52
    Quote Originally Posted by SlyMaelstrom
    Try writing C++ in notepad.
    Aw, heck, let's start 2 holy wars in one thread! Use vim! *dons flame-proof suit*

  9. #24
    chococoder
    Join Date
    Nov 2004
    Posts
    515
    Quote Originally Posted by Rashakil Fol
    See what happens when you mention these on a programming forum? I hope you learned your lesson.
    Unless it's a Python or Pascal forum of course

  10. #25
    aoeuhtns
    Join Date
    Jul 2005
    Posts
    581
    Quote Originally Posted by jwenting
    Unless it's a Python or Pascal forum of course
    But then in Python you get people arguing over using tab characters or spaces.

  11. #26
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    Omg spaces > Tab. Its a proven fact. First off, a tab brings to many spaces, its like this: 1. But a space, is so nice! Its like this: 1. See? Its so much better, and in code:

    Code:
    int main() {
     cout << "Hi";
    }
    But with tab...

    Code:
    int main() {
           cout << "Hi";
    }
    *pukes*

    So, I conclude Tab < space, because space not only provides more control, but I use it. . (The holy war begins again lol)
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  12. #27
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,109
    I always use tabs, that is after setting my IDE so it will automatically convert a tab to 2 spaces .

  13. #28
    chococoder
    Join Date
    Nov 2004
    Posts
    515
    Quote Originally Posted by Rashakil Fol
    But then in Python you get people arguing over using tab characters or spaces.
    real programmers use a mix

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. is curly braces here is a must?
    By mashour06 in forum C Programming
    Replies: 8
    Last Post: 04-25-2009, 04:41 PM
  2. error: braces around scalar initializer...
    By Osiris990 in forum C++ Programming
    Replies: 2
    Last Post: 02-27-2008, 02:22 PM
  3. What Do Braces Do?
    By jrahhali in forum C++ Programming
    Replies: 11
    Last Post: 04-18-2004, 04:14 PM
  4. Local stacks, curly braces
    By bennyandthejets in forum C++ Programming
    Replies: 2
    Last Post: 07-11-2003, 11:48 PM
  5. Replies: 1
    Last Post: 12-01-2001, 07:17 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21