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. Style is a subtle thing...

Style is a subtle thing...

Scheduled Pinned Locked Moved The Lounge
questioncsharpc++comcollaboration
37 Posts 29 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.
  • N Nemanja Trifunovic

    A recent StackOverflow discussion got me thinking... Apparently somebody did something like:

    *(*(*(p_member).p_member).p_member).member

    and the other guy said "WTF" and changed it to something like:

    p_member->p_member->p_member->member

    and offended the guy No. 1 who prefers his own style. Now, I don't want to steal the SO thread and discuss what is better - most if not all of us will agree with the guy 2 that operator -> is the preffered approach here. But would you make a change like this and start a war with someone you work with? I mean, the code is still correct, even if ugly, and the customers will never notice any difference. On the other hand, if you turn the development team into a bunch of people who hate each other, everybody is going to suffer. I guess my question is: would you rather have "beautiful" code or good relationship with your coworkers?

    Programming Blog utf8-cpp

    M Offline
    M Offline
    macu
    wrote on last edited by
    #21

    I definitely avoid this for three reasons: 1. It winds people up, sometimes a lot. 2. You look very stupid when you amend something for style and accidentally introduce a new bug. 3. You introduce changes into the source history in your source code control software that aren't meaningful and actual changes become harder to see. A guy where I work got hold of a copy of resharper and did all of the above in a big way (yep bugs too). I use resharper and it's very good but it's not a good idea to randomly open other people's code with it just to reformat...

    N 1 Reply Last reply
    0
    • N Nemanja Trifunovic

      A recent StackOverflow discussion got me thinking... Apparently somebody did something like:

      *(*(*(p_member).p_member).p_member).member

      and the other guy said "WTF" and changed it to something like:

      p_member->p_member->p_member->member

      and offended the guy No. 1 who prefers his own style. Now, I don't want to steal the SO thread and discuss what is better - most if not all of us will agree with the guy 2 that operator -> is the preffered approach here. But would you make a change like this and start a war with someone you work with? I mean, the code is still correct, even if ugly, and the customers will never notice any difference. On the other hand, if you turn the development team into a bunch of people who hate each other, everybody is going to suffer. I guess my question is: would you rather have "beautiful" code or good relationship with your coworkers?

      Programming Blog utf8-cpp

      U Offline
      U Offline
      urbane tiger
      wrote on last edited by
      #22

      The following's relationship to your question is somewhat oblique, but nevertheless I think it's germaine. After examining the first module I'd written at what was then my new workplace, the chief code stylist told me, "We do not allow use of computed procedure calls (function pointers) round here". "Why not?" I asked. "Because the compiler has a bug" he replied. "What bug? Show me" I demanded. "This one" he replied, pulling a 15x11 listing from the shelf and referring me to the apparently errant code, which did indeed make use of computed procedure calls. Äfter a few moments of reading I asked "Does it fall over with a bounds error?" "Yes. How did you know that?" he replied with some surprise. "Because there's a GOTO in here that jumps into the middle of a FOR loop" I smugly replied. Needless to say I was able to lift the ban on computed procedure calls, and after that many other constraints on the liberty and freedom of programmers to write the code that they thought best suited the problem. In later years, with some help from the likes Edsger Djikstra and Nicklaus Wirth, I was able to impose an embargo on the use of GOTO, not to be used without prior approval of the then chief code stylist, who was by then -- you can guess who. I had great relationships with my colleagues, especially Deb.... and Elsp... and ...., salad days long gone.

      Multi famam, conscientiam pauci verentur.(Pliny)

      modified on Wednesday, April 29, 2009 2:56 AM

      1 Reply Last reply
      0
      • N Nemanja Trifunovic

        A recent StackOverflow discussion got me thinking... Apparently somebody did something like:

        *(*(*(p_member).p_member).p_member).member

        and the other guy said "WTF" and changed it to something like:

        p_member->p_member->p_member->member

        and offended the guy No. 1 who prefers his own style. Now, I don't want to steal the SO thread and discuss what is better - most if not all of us will agree with the guy 2 that operator -> is the preffered approach here. But would you make a change like this and start a war with someone you work with? I mean, the code is still correct, even if ugly, and the customers will never notice any difference. On the other hand, if you turn the development team into a bunch of people who hate each other, everybody is going to suffer. I guess my question is: would you rather have "beautiful" code or good relationship with your coworkers?

        Programming Blog utf8-cpp

        L Offline
        L Offline
        Lonnie R Thomas
        wrote on last edited by
        #23

        code writing is an individual thing. Instead of automatically changing the code or remarking it just talk to the person. Change just for the sake of change is inappropriate. But good communication with your coworkers is the most important issue here. In my case the more experience programmers look at my code and suggest mayber a better looking way but do not hassle me about it. When the end result is the same. Simply talk to each other like adults. ;)

        Lonnie R Thomas

        1 Reply Last reply
        0
        • N Nemanja Trifunovic

          A recent StackOverflow discussion got me thinking... Apparently somebody did something like:

          *(*(*(p_member).p_member).p_member).member

          and the other guy said "WTF" and changed it to something like:

          p_member->p_member->p_member->member

          and offended the guy No. 1 who prefers his own style. Now, I don't want to steal the SO thread and discuss what is better - most if not all of us will agree with the guy 2 that operator -> is the preffered approach here. But would you make a change like this and start a war with someone you work with? I mean, the code is still correct, even if ugly, and the customers will never notice any difference. On the other hand, if you turn the development team into a bunch of people who hate each other, everybody is going to suffer. I guess my question is: would you rather have "beautiful" code or good relationship with your coworkers?

          Programming Blog utf8-cpp

          B Offline
          B Offline
          Bob1000
          wrote on last edited by
          #24

          Speaking as a person who has to modify (fix) code many years after the writer may have disappeared (grrr!). Readable and understandable code first!!!!!!! The code writer ought to learn its not just writing the code in the first place it has to be maintained, if nothing is said nothing is learned!

          1 Reply Last reply
          0
          • J Jim Crafton

            Maxxx_ wrote:

            The relationship with my co-workers depends upon their sex, age and willingness to get drunk at the Xmas party and fool around in the stationery cupboard.

            That's gotta be the best response ever! Though I'm not sure HR would approve...unless of course HR looks like Salma Hayak, and has a serious sex addiction! :)

            ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Oh

            S Offline
            S Offline
            sketch2002
            wrote on last edited by
            #25

            Jim Crafton wrote:

            and has a serious sex addiction!

            Unless HR is the one with the... how did he put it... Oh yes:

            Jim Crafton wrote:

            willingness to get drunk at the Xmas party and fool around in the stationery cupboard.

            1 Reply Last reply
            0
            • M macu

              I definitely avoid this for three reasons: 1. It winds people up, sometimes a lot. 2. You look very stupid when you amend something for style and accidentally introduce a new bug. 3. You introduce changes into the source history in your source code control software that aren't meaningful and actual changes become harder to see. A guy where I work got hold of a copy of resharper and did all of the above in a big way (yep bugs too). I use resharper and it's very good but it's not a good idea to randomly open other people's code with it just to reformat...

              N Offline
              N Offline
              Nish Nishant
              wrote on last edited by
              #26

              5. This is the best answer here. :thumbsup:

              Regards, Nish


              Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
              My latest book : C++/CLI in Action / Amazon.com link

              N 1 Reply Last reply
              0
              • N Nemanja Trifunovic

                A recent StackOverflow discussion got me thinking... Apparently somebody did something like:

                *(*(*(p_member).p_member).p_member).member

                and the other guy said "WTF" and changed it to something like:

                p_member->p_member->p_member->member

                and offended the guy No. 1 who prefers his own style. Now, I don't want to steal the SO thread and discuss what is better - most if not all of us will agree with the guy 2 that operator -> is the preffered approach here. But would you make a change like this and start a war with someone you work with? I mean, the code is still correct, even if ugly, and the customers will never notice any difference. On the other hand, if you turn the development team into a bunch of people who hate each other, everybody is going to suffer. I guess my question is: would you rather have "beautiful" code or good relationship with your coworkers?

                Programming Blog utf8-cpp

                E Offline
                E Offline
                Ed Leighton Dick
                wrote on last edited by
                #27

                Not to be petty, but both of them need to grow up. They need to realize that personal styles have only a small place in IT development, and the larger the shop, the smaller the room for a personal style. In many cases, if it works, it's right, regardless of whether it looks good or not. Person #2 shouldn't have made the change, but person #1 shouldn't have been offended that someone else changed "his" code.

                1 Reply Last reply
                0
                • N Nish Nishant

                  5. This is the best answer here. :thumbsup:

                  Regards, Nish


                  Nish’s thoughts on MFC, C++/CLI and .NET (my blog)
                  My latest book : C++/CLI in Action / Amazon.com link

                  N Offline
                  N Offline
                  Nemanja Trifunovic
                  wrote on last edited by
                  #28

                  Nishant Sivakumar wrote:

                  This is the best answer here

                  Seconded.

                  Programming Blog utf8-cpp

                  1 Reply Last reply
                  0
                  • N Nemanja Trifunovic

                    A recent StackOverflow discussion got me thinking... Apparently somebody did something like:

                    *(*(*(p_member).p_member).p_member).member

                    and the other guy said "WTF" and changed it to something like:

                    p_member->p_member->p_member->member

                    and offended the guy No. 1 who prefers his own style. Now, I don't want to steal the SO thread and discuss what is better - most if not all of us will agree with the guy 2 that operator -> is the preffered approach here. But would you make a change like this and start a war with someone you work with? I mean, the code is still correct, even if ugly, and the customers will never notice any difference. On the other hand, if you turn the development team into a bunch of people who hate each other, everybody is going to suffer. I guess my question is: would you rather have "beautiful" code or good relationship with your coworkers?

                    Programming Blog utf8-cpp

                    O Offline
                    O Offline
                    Old Ed
                    wrote on last edited by
                    #29

                    If you understand the code and it works then just leave it alone. It's absolutely ridiculous to get into a pissing contest over style. Additionally, style guidelines should already have been established. Lastly, once you've written code just let it go.

                    1 Reply Last reply
                    0
                    • N Nemanja Trifunovic

                      A recent StackOverflow discussion got me thinking... Apparently somebody did something like:

                      *(*(*(p_member).p_member).p_member).member

                      and the other guy said "WTF" and changed it to something like:

                      p_member->p_member->p_member->member

                      and offended the guy No. 1 who prefers his own style. Now, I don't want to steal the SO thread and discuss what is better - most if not all of us will agree with the guy 2 that operator -> is the preffered approach here. But would you make a change like this and start a war with someone you work with? I mean, the code is still correct, even if ugly, and the customers will never notice any difference. On the other hand, if you turn the development team into a bunch of people who hate each other, everybody is going to suffer. I guess my question is: would you rather have "beautiful" code or good relationship with your coworkers?

                      Programming Blog utf8-cpp

                      D Offline
                      D Offline
                      Doug Rogers
                      wrote on last edited by
                      #30

                      What you may think is beautiful, is not necessarily what everyone else thinks is beautiful. At my last job, we had a philosophy: When changing someone else's code, use their style. I would leave the code, but attempt to get a coding standard for the company. So when you wanted to change the code to ->, it would be per the company standard.

                      1 Reply Last reply
                      0
                      • L Lost User

                        Nemanja Trifunovic wrote:

                        I guess my question is: would you rather have "beautiful" code or good relationship with your coworkers?

                        The relationship with my co-workers depends upon their sex, age and willingness to get drunk at the Xmas party and fool around in the stationery cupboard. The beauty of any code lies in the eye of the beholder, and code, having all the attibutes of a woman, has needs, wants and a particular inner beauty that is at once obvious and indescribable.

                        ___________________________________________ .\\axxx (That's an 'M')

                        P Offline
                        P Offline
                        pdelayCA
                        wrote on last edited by
                        #31

                        Maxxx_ wrote:

                        The beauty of any code lies in the eye of the beholder ... inner beauty that is at once obvious and indescribable

                        I agree with this comment so wholeheartedly that I put it up on my whiteboard (I also have it signed Maxxx_ [CodeProject]). I cannot seem to move past the memories of the coutless times I have looked over other's code work, and rated them according to maturity of style. I am quite sure that if it were possible to analyze my coding over the past 12 years, you would see a progression of stick-figure crayon drawings gradualy merging into detailed oil paintings. Though my works probably will never come close to the masters of today, they are products of my imagination and assembled through my blood, sweat, and tears. A lot of me goes into everything I make, therefore it is hard not to have an attachment to the code I have constructed. BUT, I am open to new methods and concepts, which means that I will always be searching for ways to improve my craft. I am willing to accept a critical eye and helpful suggestions, as long as they are respectful of the effort I have already applied. Ultimately, my point is that I agree that the "The beauty of any code lies in the eye of the beholder...", whereas it is all to easy to overlook the effort behind the finished product. Keep that in mind the next time you look over someone else's code.

                        1 Reply Last reply
                        0
                        • N Nemanja Trifunovic

                          A recent StackOverflow discussion got me thinking... Apparently somebody did something like:

                          *(*(*(p_member).p_member).p_member).member

                          and the other guy said "WTF" and changed it to something like:

                          p_member->p_member->p_member->member

                          and offended the guy No. 1 who prefers his own style. Now, I don't want to steal the SO thread and discuss what is better - most if not all of us will agree with the guy 2 that operator -> is the preffered approach here. But would you make a change like this and start a war with someone you work with? I mean, the code is still correct, even if ugly, and the customers will never notice any difference. On the other hand, if you turn the development team into a bunch of people who hate each other, everybody is going to suffer. I guess my question is: would you rather have "beautiful" code or good relationship with your coworkers?

                          Programming Blog utf8-cpp

                          J Offline
                          J Offline
                          James Lonero
                          wrote on last edited by
                          #32

                          Actually, there should be a code standard for the group and/or company that spells out items like this. One of the holiest of the styles is the placement of the braces { }. But, the code standards for the organization should spell this out and the code standard should be updated regularly. But, most places that I have worked have coding standards.

                          1 Reply Last reply
                          0
                          • N Nemanja Trifunovic

                            A recent StackOverflow discussion got me thinking... Apparently somebody did something like:

                            *(*(*(p_member).p_member).p_member).member

                            and the other guy said "WTF" and changed it to something like:

                            p_member->p_member->p_member->member

                            and offended the guy No. 1 who prefers his own style. Now, I don't want to steal the SO thread and discuss what is better - most if not all of us will agree with the guy 2 that operator -> is the preffered approach here. But would you make a change like this and start a war with someone you work with? I mean, the code is still correct, even if ugly, and the customers will never notice any difference. On the other hand, if you turn the development team into a bunch of people who hate each other, everybody is going to suffer. I guess my question is: would you rather have "beautiful" code or good relationship with your coworkers?

                            Programming Blog utf8-cpp

                            P Offline
                            P Offline
                            patbob
                            wrote on last edited by
                            #33

                            Co-workers. "Beautiful" code doesn't help gets projects done on time, prevent bugs or fix bugs. Putting up with prima donnas is no longer a necessary evil of software development.

                            patbob

                            1 Reply Last reply
                            0
                            • B Big Daddy Farang

                              Nemanja Trifunovic wrote:

                              would you rather have "beautiful" code or good relationship with your coworkers?

                              I'd sort of like to have both. :) I don't think I'd change the first guy's code if he was still in the company. I might add a comment,

                              // a sane person would write:
                              // p_member->p_member->p_member->member

                              and let the chips fall where they may.

                              BDF People don't mind being mean; but they never want to be ridiculous. -- Moliere

                              F Offline
                              F Offline
                              Fahad Sadah
                              wrote on last edited by
                              #34

                              Or

                              //aka
                              // p_member->p_member->p_member->member

                              1 Reply Last reply
                              0
                              • N Nemanja Trifunovic

                                A recent StackOverflow discussion got me thinking... Apparently somebody did something like:

                                *(*(*(p_member).p_member).p_member).member

                                and the other guy said "WTF" and changed it to something like:

                                p_member->p_member->p_member->member

                                and offended the guy No. 1 who prefers his own style. Now, I don't want to steal the SO thread and discuss what is better - most if not all of us will agree with the guy 2 that operator -> is the preffered approach here. But would you make a change like this and start a war with someone you work with? I mean, the code is still correct, even if ugly, and the customers will never notice any difference. On the other hand, if you turn the development team into a bunch of people who hate each other, everybody is going to suffer. I guess my question is: would you rather have "beautiful" code or good relationship with your coworkers?

                                Programming Blog utf8-cpp

                                E Offline
                                E Offline
                                Ennis Ray Lynch Jr
                                wrote on last edited by
                                #35

                                Never change someone else code unless you are correcting an error or adding a feature. Stylistic changes, while innocuous must still be thoroughly tested. With regard to the code snippet it isn't even valid anyway in either case as both fail when the level is not assigned.

                                Need custom software developed? I do C# development and consulting all over the United States. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane

                                1 Reply Last reply
                                0
                                • N Nemanja Trifunovic

                                  A recent StackOverflow discussion got me thinking... Apparently somebody did something like:

                                  *(*(*(p_member).p_member).p_member).member

                                  and the other guy said "WTF" and changed it to something like:

                                  p_member->p_member->p_member->member

                                  and offended the guy No. 1 who prefers his own style. Now, I don't want to steal the SO thread and discuss what is better - most if not all of us will agree with the guy 2 that operator -> is the preffered approach here. But would you make a change like this and start a war with someone you work with? I mean, the code is still correct, even if ugly, and the customers will never notice any difference. On the other hand, if you turn the development team into a bunch of people who hate each other, everybody is going to suffer. I guess my question is: would you rather have "beautiful" code or good relationship with your coworkers?

                                  Programming Blog utf8-cpp

                                  L Offline
                                  L Offline
                                  LenaBr
                                  wrote on last edited by
                                  #36

                                  Unless the code was once written by your boss and you accidentally use it to illustrate how not to program to all your co-workers.

                                  1 Reply Last reply
                                  0
                                  • N Nemanja Trifunovic

                                    A recent StackOverflow discussion got me thinking... Apparently somebody did something like:

                                    *(*(*(p_member).p_member).p_member).member

                                    and the other guy said "WTF" and changed it to something like:

                                    p_member->p_member->p_member->member

                                    and offended the guy No. 1 who prefers his own style. Now, I don't want to steal the SO thread and discuss what is better - most if not all of us will agree with the guy 2 that operator -> is the preffered approach here. But would you make a change like this and start a war with someone you work with? I mean, the code is still correct, even if ugly, and the customers will never notice any difference. On the other hand, if you turn the development team into a bunch of people who hate each other, everybody is going to suffer. I guess my question is: would you rather have "beautiful" code or good relationship with your coworkers?

                                    Programming Blog utf8-cpp

                                    D Offline
                                    D Offline
                                    dpminusa
                                    wrote on last edited by
                                    #37

                                    Maybe the example is too simple. What are the objectives of your style guide? Some simple ones include: 1. Self-documenting - use meaningful names 2. Easy of maintenance by all project members - use code you would like to have to maintain yourself 3. No unnecessary/redundant code - use the full recommended, language features 4. No unsafe/incomplete constructs - consider correct and incorrect data may reach this section 5. No insecure code - open to hacks, injections, etc. Do you consider technique and style to be different things? Perhaps your example is more technique that style? To me, style is the art and technique is the science. As someone else pointed out, constructively convincing may be the way to go. I have had success with two opposing members trying to maintain each others code. They may see the point to the style guide and compromise. Not to sound too PollyAnna - then everyone wins.

                                    "Coding for fun and profit ... mostly fun"

                                    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