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. code aesthetics

code aesthetics

Scheduled Pinned Locked Moved The Lounge
comquestiondiscussion
103 Posts 42 Posters 0 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.
  • M Marc Clifton

    I take care to ensure the aesthetics of my code. That spacing and formatting is consistent. I don't care if I'm writing throw away code or production code. The code should always look neat and tidy. Why don't other programmers do the same??? OK, I'm sure there are some out there. And yes, there are code beautifiers, so who really cares, right? What's your thoughts on whether code should look good, in terms of spacing, formatting, structure, etc.? Marc

    Thyme In The Country Interacx My Blog

    T Offline
    T Offline
    Tom Deketelaere
    wrote on last edited by
    #2

    I try to do the same, but isn't this sort of relative, what looks good for one programmer may look like crap for another. Of course some rules are very basic (like not letting code be longer then the width of a normal screen) and should always be followed (I think)

    S G A 3 Replies Last reply
    0
    • M Marc Clifton

      I take care to ensure the aesthetics of my code. That spacing and formatting is consistent. I don't care if I'm writing throw away code or production code. The code should always look neat and tidy. Why don't other programmers do the same??? OK, I'm sure there are some out there. And yes, there are code beautifiers, so who really cares, right? What's your thoughts on whether code should look good, in terms of spacing, formatting, structure, etc.? Marc

      Thyme In The Country Interacx My Blog

      D Offline
      D Offline
      Douglas Troy
      wrote on last edited by
      #3

      I agree: even if I'm hacking something out I have no intentions of putting into production, I almost always ensure proper formatting/structure. Hell, I'll even put comments in, thinking if I do end-up keeping this around, I'll want notes as to why I created it, what it was for and how it works. I think this kind of mentality comes more from experience, than anything else. I know that I didn't used to take this kind of approach, and I learned, a good while back, taking the time upfront to do this 'extra' work, almost always pays off in the long run.


      :..::. Douglas H. Troy ::..
      Bad Astronomy |VCF|wxWidgets|WTL

      D 1 Reply Last reply
      0
      • M Marc Clifton

        I take care to ensure the aesthetics of my code. That spacing and formatting is consistent. I don't care if I'm writing throw away code or production code. The code should always look neat and tidy. Why don't other programmers do the same??? OK, I'm sure there are some out there. And yes, there are code beautifiers, so who really cares, right? What's your thoughts on whether code should look good, in terms of spacing, formatting, structure, etc.? Marc

        Thyme In The Country Interacx My Blog

        O Offline
        O Offline
        Oakman
        wrote on last edited by
        #4

        Marc Clifton wrote:

        I don't care if I'm writing throw away code or production code. The code should always look neat and tidy.

        I couldn't agree more. If the team or company has standards - follow 'em. If not, then spend the time and take the care to make your code presentable and consistent.

        Jon Smith & Wesson: The original point and click interface

        1 Reply Last reply
        0
        • M Marc Clifton

          I take care to ensure the aesthetics of my code. That spacing and formatting is consistent. I don't care if I'm writing throw away code or production code. The code should always look neat and tidy. Why don't other programmers do the same??? OK, I'm sure there are some out there. And yes, there are code beautifiers, so who really cares, right? What's your thoughts on whether code should look good, in terms of spacing, formatting, structure, etc.? Marc

          Thyme In The Country Interacx My Blog

          M Offline
          M Offline
          Matthew Faithfull
          wrote on last edited by
          #5

          Yes code should look good. i.e. be well and consistently laid out. Mostly so it can be read and therefore understood and therefore maintained by others. I try to follow some basic rules although I won't bow to the 40 column zealots in these days of wide screens and dual monitors. I've been writing at least 80 column code since 1985 and I'll go on doing so until my code is required to be good for sending back in time to be used in the 1970s. :) BTW Anyone who thinks they're hardcore and don't need well laid out code to be able to understand it should have a look at the C++ standard library headers e.g . An object lesson in how not to layout code if ever I've seen one. Considering this stuff is supposed to be 'standard' it's an utter disaster that this example is put in front of people trying to learn to do C++ properly. Elsewhere in library 6 class and 3000 lines of code in one header means someone needs a std::slap< hard, hand< right >, promptly< second_tenths > >( 4 ); Even proper formatting isn't going to make a file like that readable.

          "The secret of happiness is freedom, and the secret of freedom, courage." Thucydides (B.C. 460-400)

          1 Reply Last reply
          0
          • M Marc Clifton

            I take care to ensure the aesthetics of my code. That spacing and formatting is consistent. I don't care if I'm writing throw away code or production code. The code should always look neat and tidy. Why don't other programmers do the same??? OK, I'm sure there are some out there. And yes, there are code beautifiers, so who really cares, right? What's your thoughts on whether code should look good, in terms of spacing, formatting, structure, etc.? Marc

            Thyme In The Country Interacx My Blog

            R Offline
            R Offline
            Rama Krishna Vavilala
            wrote on last edited by
            #6

            No I like code like this:

                                                                    int i 
            

            = 0;
            while (i < 100) { if (i%2) == 0 {
            Console.WriteLine(i); Method1(); } }

            Pros: 1. The code compiles and runs correctly 2. It's difficult for others to understand 3. Debugging is also difficult as sometimes the debugger gets confused. No need to buy an obfuscator. 4. Tests pass 5. Company makes millions 6. Any other programmer debugging my code will feel a sense of achievement if he fixes something.

            Any fool can write code that a computer can understand. Good programmers write code that humans can understand. - Martin Fowler

            D S G L 4 Replies Last reply
            0
            • M Marc Clifton

              I take care to ensure the aesthetics of my code. That spacing and formatting is consistent. I don't care if I'm writing throw away code or production code. The code should always look neat and tidy. Why don't other programmers do the same??? OK, I'm sure there are some out there. And yes, there are code beautifiers, so who really cares, right? What's your thoughts on whether code should look good, in terms of spacing, formatting, structure, etc.? Marc

              Thyme In The Country Interacx My Blog

              S Offline
              S Offline
              stephen hazel
              wrote on last edited by
              #7

              Ooooooo - that strikes a nerve with ME alright. I am a column nazi. People. Can't we at least agree that code shouldn't be wider than 120 columns? (I prefer a width of 80 myself). And for GOD'S SAKE why won't some of you indent your code????? I don't care if it's 3 spaces or 4 or a tab or what, but PLEEEASE! I'm BEGGING YOUuuuuuuu......... Why? Why can't you just keep it on one screen and indent? Is the reason because it takes time to write it that way? (once) And it's just as easy for YOU to read it that way? (80 times) Whyyyyyyy??? I really wanna know...

              G T B 3 Replies Last reply
              0
              • R Rama Krishna Vavilala

                No I like code like this:

                                                                        int i 
                

                = 0;
                while (i < 100) { if (i%2) == 0 {
                Console.WriteLine(i); Method1(); } }

                Pros: 1. The code compiles and runs correctly 2. It's difficult for others to understand 3. Debugging is also difficult as sometimes the debugger gets confused. No need to buy an obfuscator. 4. Tests pass 5. Company makes millions 6. Any other programmer debugging my code will feel a sense of achievement if he fixes something.

                Any fool can write code that a computer can understand. Good programmers write code that humans can understand. - Martin Fowler

                D Offline
                D Offline
                Douglas Troy
                wrote on last edited by
                #8

                You should really expand this concept, and implement unnecessary casting where possible. :rolleyes:


                :..::. Douglas H. Troy ::..
                Bad Astronomy |VCF|wxWidgets|WTL

                L 1 Reply Last reply
                0
                • D Douglas Troy

                  I agree: even if I'm hacking something out I have no intentions of putting into production, I almost always ensure proper formatting/structure. Hell, I'll even put comments in, thinking if I do end-up keeping this around, I'll want notes as to why I created it, what it was for and how it works. I think this kind of mentality comes more from experience, than anything else. I know that I didn't used to take this kind of approach, and I learned, a good while back, taking the time upfront to do this 'extra' work, almost always pays off in the long run.


                  :..::. Douglas H. Troy ::..
                  Bad Astronomy |VCF|wxWidgets|WTL

                  D Offline
                  D Offline
                  Dan Neely
                  wrote on last edited by
                  #9

                  Agreed. I tended to be a bit sloppy when in school, dealing with someone elses sloppy code when I got my job cured me of that real quick.

                  Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots. -- Robert Royall

                  1 Reply Last reply
                  0
                  • R Rama Krishna Vavilala

                    No I like code like this:

                                                                            int i 
                    

                    = 0;
                    while (i < 100) { if (i%2) == 0 {
                    Console.WriteLine(i); Method1(); } }

                    Pros: 1. The code compiles and runs correctly 2. It's difficult for others to understand 3. Debugging is also difficult as sometimes the debugger gets confused. No need to buy an obfuscator. 4. Tests pass 5. Company makes millions 6. Any other programmer debugging my code will feel a sense of achievement if he fixes something.

                    Any fool can write code that a computer can understand. Good programmers write code that humans can understand. - Martin Fowler

                    S Offline
                    S Offline
                    stephen hazel
                    wrote on last edited by
                    #10

                    Ok. That's hilarious. Seriously. I was rollin'... But that's not funny.

                    1 Reply Last reply
                    0
                    • M Marc Clifton

                      I take care to ensure the aesthetics of my code. That spacing and formatting is consistent. I don't care if I'm writing throw away code or production code. The code should always look neat and tidy. Why don't other programmers do the same??? OK, I'm sure there are some out there. And yes, there are code beautifiers, so who really cares, right? What's your thoughts on whether code should look good, in terms of spacing, formatting, structure, etc.? Marc

                      Thyme In The Country Interacx My Blog

                      B Offline
                      B Offline
                      Bert delaVega
                      wrote on last edited by
                      #11

                      Absolutely agree or it would be like writing a book with disregard to pagination, margins, paragraphs and chapters. In the end, source code is the product and a product should look professional.

                      1 Reply Last reply
                      0
                      • R Rama Krishna Vavilala

                        No I like code like this:

                                                                                int i 
                        

                        = 0;
                        while (i < 100) { if (i%2) == 0 {
                        Console.WriteLine(i); Method1(); } }

                        Pros: 1. The code compiles and runs correctly 2. It's difficult for others to understand 3. Debugging is also difficult as sometimes the debugger gets confused. No need to buy an obfuscator. 4. Tests pass 5. Company makes millions 6. Any other programmer debugging my code will feel a sense of achievement if he fixes something.

                        Any fool can write code that a computer can understand. Good programmers write code that humans can understand. - Martin Fowler

                        G Offline
                        G Offline
                        Graham Shanks
                        wrote on last edited by
                        #12

                        I like the dichotomy between your post and your sig

                        Graham Librarians rule, Ook!

                        1 Reply Last reply
                        0
                        • S stephen hazel

                          Ooooooo - that strikes a nerve with ME alright. I am a column nazi. People. Can't we at least agree that code shouldn't be wider than 120 columns? (I prefer a width of 80 myself). And for GOD'S SAKE why won't some of you indent your code????? I don't care if it's 3 spaces or 4 or a tab or what, but PLEEEASE! I'm BEGGING YOUuuuuuuu......... Why? Why can't you just keep it on one screen and indent? Is the reason because it takes time to write it that way? (once) And it's just as easy for YOU to read it that way? (80 times) Whyyyyyyy??? I really wanna know...

                          G Offline
                          G Offline
                          Graham Bradshaw
                          wrote on last edited by
                          #13

                          Steve Hazel wrote:

                          (I prefer a width of 80 myself).

                          I'm guessing you either don't indent much, or have really short function and variable names.

                          S 1 Reply Last reply
                          0
                          • M Marc Clifton

                            I take care to ensure the aesthetics of my code. That spacing and formatting is consistent. I don't care if I'm writing throw away code or production code. The code should always look neat and tidy. Why don't other programmers do the same??? OK, I'm sure there are some out there. And yes, there are code beautifiers, so who really cares, right? What's your thoughts on whether code should look good, in terms of spacing, formatting, structure, etc.? Marc

                            Thyme In The Country Interacx My Blog

                            E Offline
                            E Offline
                            El Corazon
                            wrote on last edited by
                            #14

                            Marc Clifton wrote:

                            OK, I'm sure there are some out there. And yes, there are code beautifiers, so who really cares, right? What's your thoughts on whether code should look good, in terms of spacing, formatting, structure, etc.?

                            What I see is that every programmer has their own way of doing "good formatting" we tried for 2.5 years in meetings ( :rolleyes: ) to get a consensus, it was unreachable. We finally agreed on a format through a document forced into the chain, but no one will enforce it, so we still have the same status quo. I personally think every programmer on his own should write clean looking code, whether by beautifier or 1st time out writing I don't care. A team should have a tool to either verify consistency or beautify to consistant format. :)

                            _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb) John Andrew Holmes "It is well to remember that the entire universe, with one trifling exception, is composed of others."

                            L S M D 4 Replies Last reply
                            0
                            • R Rama Krishna Vavilala

                              No I like code like this:

                                                                                      int i 
                              

                              = 0;
                              while (i < 100) { if (i%2) == 0 {
                              Console.WriteLine(i); Method1(); } }

                              Pros: 1. The code compiles and runs correctly 2. It's difficult for others to understand 3. Debugging is also difficult as sometimes the debugger gets confused. No need to buy an obfuscator. 4. Tests pass 5. Company makes millions 6. Any other programmer debugging my code will feel a sense of achievement if he fixes something.

                              Any fool can write code that a computer can understand. Good programmers write code that humans can understand. - Martin Fowler

                              L Offline
                              L Offline
                              LittleYellowBird
                              wrote on last edited by
                              #15

                              I like the way you think :) However, may I suggest a small improvement in efficiency? I have found that by placing as much code as possible on a single line I save time - not having to press the ENTER key! I think you have been extravagent using 4 lines for this code sample .... ;)

                              Ali

                              1 Reply Last reply
                              0
                              • M Marc Clifton

                                I take care to ensure the aesthetics of my code. That spacing and formatting is consistent. I don't care if I'm writing throw away code or production code. The code should always look neat and tidy. Why don't other programmers do the same??? OK, I'm sure there are some out there. And yes, there are code beautifiers, so who really cares, right? What's your thoughts on whether code should look good, in terms of spacing, formatting, structure, etc.? Marc

                                Thyme In The Country Interacx My Blog

                                M Offline
                                M Offline
                                martin_hughes
                                wrote on last edited by
                                #16

                                Marc Clifton wrote:

                                What's your thoughts on whether code should look good, in terms of spacing, formatting, structure, etc.?

                                It's a must. I like to be able to squint at code and see pretty patterns in the text, which is as near as dammit impossible if due care and attention has not been taken by the monkey bashing the keys (or if it's written in Perl :) ).

                                Top Secret Plan for World Domination

                                B 1 Reply Last reply
                                0
                                • M Marc Clifton

                                  I take care to ensure the aesthetics of my code. That spacing and formatting is consistent. I don't care if I'm writing throw away code or production code. The code should always look neat and tidy. Why don't other programmers do the same??? OK, I'm sure there are some out there. And yes, there are code beautifiers, so who really cares, right? What's your thoughts on whether code should look good, in terms of spacing, formatting, structure, etc.? Marc

                                  Thyme In The Country Interacx My Blog

                                  S Offline
                                  S Offline
                                  Scott Dorman
                                  wrote on last edited by
                                  #17

                                  Marc Clifton wrote:

                                  What's your thoughts on whether code should look good, in terms of spacing, formatting, structure, etc.?

                                  Absolutely! There are tons of benefits to having and following a consistent style.

                                  Marc Clifton wrote:

                                  yes, there are code beautifiers, so who really cares, right?

                                  Right. To me, code beautifiers defeat the purpose of having a code style/standard, which is that it should be simple enough for your programmers to internalize so they just automatically follow the standard which will help improve the quality of the code. Beautifying it "after the fact" doesn't achieve this.

                                  Scott Dorman

                                  Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]


                                  Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

                                  1 Reply Last reply
                                  0
                                  • E El Corazon

                                    Marc Clifton wrote:

                                    OK, I'm sure there are some out there. And yes, there are code beautifiers, so who really cares, right? What's your thoughts on whether code should look good, in terms of spacing, formatting, structure, etc.?

                                    What I see is that every programmer has their own way of doing "good formatting" we tried for 2.5 years in meetings ( :rolleyes: ) to get a consensus, it was unreachable. We finally agreed on a format through a document forced into the chain, but no one will enforce it, so we still have the same status quo. I personally think every programmer on his own should write clean looking code, whether by beautifier or 1st time out writing I don't care. A team should have a tool to either verify consistency or beautify to consistant format. :)

                                    _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb) John Andrew Holmes "It is well to remember that the entire universe, with one trifling exception, is composed of others."

                                    L Offline
                                    L Offline
                                    leppie
                                    wrote on last edited by
                                    #18

                                    C# is easy, delete the last curly brace in the file, and just create it again. Voila, code formatted :)

                                    xacc.ide - now with TabsToSpaces support
                                    IronScheme - 1.0 alpha 4a out now (29 May 2008)

                                    E 1 Reply Last reply
                                    0
                                    • T Tom Deketelaere

                                      I try to do the same, but isn't this sort of relative, what looks good for one programmer may look like crap for another. Of course some rules are very basic (like not letting code be longer then the width of a normal screen) and should always be followed (I think)

                                      S Offline
                                      S Offline
                                      Scott Dorman
                                      wrote on last edited by
                                      #19

                                      If everyone is working for the same company they should all be following the same standard. This alleviates (mostly) the problem of relativity. Of course, getting everyone to agree and follow the standard is a completely different problem.

                                      Scott Dorman

                                      Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]


                                      Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

                                      T 1 Reply Last reply
                                      0
                                      • D Douglas Troy

                                        You should really expand this concept, and implement unnecessary casting where possible. :rolleyes:


                                        :..::. Douglas H. Troy ::..
                                        Bad Astronomy |VCF|wxWidgets|WTL

                                        L Offline
                                        L Offline
                                        Lost User
                                        wrote on last edited by
                                        #20

                                        You could have a class CDOSomething and a useful member function D0Something so people mistake it for the constructor.

                                        Visit http://www.notreadytogiveup.com/[^] and do something special today.

                                        1 Reply Last reply
                                        0
                                        • E El Corazon

                                          Marc Clifton wrote:

                                          OK, I'm sure there are some out there. And yes, there are code beautifiers, so who really cares, right? What's your thoughts on whether code should look good, in terms of spacing, formatting, structure, etc.?

                                          What I see is that every programmer has their own way of doing "good formatting" we tried for 2.5 years in meetings ( :rolleyes: ) to get a consensus, it was unreachable. We finally agreed on a format through a document forced into the chain, but no one will enforce it, so we still have the same status quo. I personally think every programmer on his own should write clean looking code, whether by beautifier or 1st time out writing I don't care. A team should have a tool to either verify consistency or beautify to consistant format. :)

                                          _________________________ Asu no koto o ieba, tenjo de nezumi ga warau. Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb) John Andrew Holmes "It is well to remember that the entire universe, with one trifling exception, is composed of others."

                                          S Offline
                                          S Offline
                                          Scott Dorman
                                          wrote on last edited by
                                          #21

                                          El Corazon wrote:

                                          we tried for 2.5 years in meetings ( ) to get a consensus, it was unreachable

                                          You spent way too long debating it then. Best rule of thumb (especially if management has bought in to the concept of a standard and is willing to enforce it somehow) is to let it argue out for an hour or two, suggest some compromises (for the tab size issue, 3 generally works well) and if no one can still agree, make it a mandate.

                                          El Corazon wrote:

                                          I personally think every programmer on his own should write clean looking code, whether by beautifier or 1st time out writing I don't care.

                                          The problem with that is you then loose the psychological aspects of writing "clean" code: The developer feels better about their skills because the code is easier to understand, works better the first time out, etc., so they want to take more ownership of the code. The more ownership they take, the less likely they will be to introduce new bugs in that code. Eventually it becomes a type of self fulfilling prophecy.

                                          El Corazon wrote:

                                          A team should have a tool to either verify consistency or beautify to consistant format.

                                          Absolutely, but that isn't always possible depending on the language.

                                          Scott Dorman

                                          Microsoft® MVP - Visual C# | MCPD President - Tampa Bay IASA [Blog][Articles][Forum Guidelines]


                                          Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai

                                          E 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