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. My sins return to haunt me

My sins return to haunt me

Scheduled Pinned Locked Moved The Lounge
csharpwpf
28 Posts 17 Posters 5 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.
  • G Gary Wheeler

    jeron1 wrote:

    K&R bracing

    Everyone knows that Allman bracing is The One True Way.

    Software Zen: delete this;

    H Offline
    H Offline
    honey the codewitch
    wrote on last edited by
    #7

    I prefer K&R in C and C++ I prefer Allman in C# and most other high level languages. Don't ask me why. I think it's just because I've gotten so used to *reading* code in those formats that I write it in those formats.

    Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

    G 1 Reply Last reply
    0
    • G Gary Wheeler

      I just came across the following comment in some code I need to modify that was written in 2008:

      // This is an ugly little hack. The effect I wanted was for the text box to
      // be the width of the list item, minus the space for the activity type
      // graphic. I also wanted the text box to wrap, and to expand vertically if
      // more space was needed. To get this to work, the MaxWidth property of the
      // box must be set. Unfortunately, due to vagaries in my understanding of
      // the WPF layout process, I don't know the "proper" way to do this so that
      // it is based on the widths and margins of the controls involved. Hence the
      // magic number 48, which is the width of the graphic, plus the margins,
      // plus some fiddle-faddle.

      Sigh :sigh: .

      Software Zen: delete this;

      J Offline
      J Offline
      Jeremy Falcon
      wrote on last edited by
      #8

      I mean, at least there was a comment about it... :laugh: :laugh: :laugh:

      Jeremy Falcon

      G 1 Reply Last reply
      0
      • G Gary Wheeler

        I just came across the following comment in some code I need to modify that was written in 2008:

        // This is an ugly little hack. The effect I wanted was for the text box to
        // be the width of the list item, minus the space for the activity type
        // graphic. I also wanted the text box to wrap, and to expand vertically if
        // more space was needed. To get this to work, the MaxWidth property of the
        // box must be set. Unfortunately, due to vagaries in my understanding of
        // the WPF layout process, I don't know the "proper" way to do this so that
        // it is based on the widths and margins of the controls involved. Hence the
        // magic number 48, which is the width of the graphic, plus the margins,
        // plus some fiddle-faddle.

        Sigh :sigh: .

        Software Zen: delete this;

        M Offline
        M Offline
        MarkTJohnson
        wrote on last edited by
        #9

        But do you now know the "proper" way to do this and will you fix the issue?

        I’ve given up trying to be calm. However, I am open to feeling slightly less agitated. I’m begging you for the benefit of everyone, don’t be STUPID.

        G 1 Reply Last reply
        0
        • H honey the codewitch

          I prefer K&R in C and C++ I prefer Allman in C# and most other high level languages. Don't ask me why. I think it's just because I've gotten so used to *reading* code in those formats that I write it in those formats.

          Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

          G Offline
          G Offline
          Gary R Wheeler
          wrote on last edited by
          #10

          I was a K&R guy until I started using C#. I use blank lines in my code to separate conceptual 'blocks'. It also helps reading code with my visual issues. Allman bracing provides that separation a lot of times without introducing extra vertical space. Using Allman for both languages just seems more natural for me now. One of the reasons I keep VS2008 around is the macro language. I have a macro that does 99% of the work converting from K&R to Allman, without rewrapping text and expressions like the Visual Studio reformatters tend to do.

          Software Zen: delete this;

          H 1 Reply Last reply
          0
          • 0 0x01AA

            Thank you very much, I'm so relieved, that I'm not the only one. I think after 30 years I can fill much more than 50 pages of such comments :-O The only excuse I have; it was always just to satisfy the customer. But that doesn't really help when you come across it again :sigh:

            G Offline
            G Offline
            Gary R Wheeler
            wrote on last edited by
            #11

            I've always liked something Dan Saks, onetime Secretary of the ANSI/ISO C++ Standards Committee, once said: "If you can say it in code, then do so. Otherwise, say it in a comment." To my mind that means comments should usually describe the why or the how code is doing something, and rarely what. My longer-winded comments are usually 'why'.

            Software Zen: delete this;

            1 Reply Last reply
            0
            • J Jeremy Falcon

              I mean, at least there was a comment about it... :laugh: :laugh: :laugh:

              Jeremy Falcon

              G Offline
              G Offline
              Gary R Wheeler
              wrote on last edited by
              #12

              I think I had foreknowledge(*) how dotty I would be in my old age. (*) Cue the obvious Dune reference; "He who controls the spice, controls the universe!"

              Software Zen: delete this;

              1 Reply Last reply
              0
              • G Gary R Wheeler

                I was a K&R guy until I started using C#. I use blank lines in my code to separate conceptual 'blocks'. It also helps reading code with my visual issues. Allman bracing provides that separation a lot of times without introducing extra vertical space. Using Allman for both languages just seems more natural for me now. One of the reasons I keep VS2008 around is the macro language. I have a macro that does 99% of the work converting from K&R to Allman, without rewrapping text and expressions like the Visual Studio reformatters tend to do.

                Software Zen: delete this;

                H Offline
                H Offline
                honey the codewitch
                wrote on last edited by
                #13

                You can do that with VS Code as well. It's a bit fiddly to change the C/C++ bracing and indent styles, but nothing a little google fu can't clear up. Then you just hit "Format Document" and bob's your uncle. I guess since I'm used to using different case styles for different languages, it's not as much of a stretch for me to adapt to different bracing? For me, C and C++ just seem more "natural" in K&R and C# just seems more natural to me in Allman. Feel and flow for me - the final form is just easier for me if I do it this way. I don't know WHY C# would be different than C or C++ for me that way, except exposure. I'm so used to seeing Allman C# and K&R C/C++ that it's familiar to me. That must be it, I think.

                Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                G 1 Reply Last reply
                0
                • M MarkTJohnson

                  But do you now know the "proper" way to do this and will you fix the issue?

                  I’ve given up trying to be calm. However, I am open to feeling slightly less agitated. I’m begging you for the benefit of everyone, don’t be STUPID.

                  G Offline
                  G Offline
                  Gary R Wheeler
                  wrote on last edited by
                  #14

                  I have reached the stage in my career (3.75 years until retirement), plus given my typical workload, that fixing this would be a poor use of my time. It works well enough and has never caused an issue. Besides, given how little love Microsoft has given WPF over the years, I doubt there is a better way to do it :rolleyes: .

                  Software Zen: delete this;

                  1 Reply Last reply
                  0
                  • G Gary Wheeler

                    I just came across the following comment in some code I need to modify that was written in 2008:

                    // This is an ugly little hack. The effect I wanted was for the text box to
                    // be the width of the list item, minus the space for the activity type
                    // graphic. I also wanted the text box to wrap, and to expand vertically if
                    // more space was needed. To get this to work, the MaxWidth property of the
                    // box must be set. Unfortunately, due to vagaries in my understanding of
                    // the WPF layout process, I don't know the "proper" way to do this so that
                    // it is based on the widths and margins of the controls involved. Hence the
                    // magic number 48, which is the width of the graphic, plus the margins,
                    // plus some fiddle-faddle.

                    Sigh :sigh: .

                    Software Zen: delete this;

                    A Offline
                    A Offline
                    Amarnath S
                    wrote on last edited by
                    #15

                    Gary Wheeler wrote:

                    magic number 48

                    Isn't it 42?

                    1 Reply Last reply
                    0
                    • G Gary Wheeler

                      I just came across the following comment in some code I need to modify that was written in 2008:

                      // This is an ugly little hack. The effect I wanted was for the text box to
                      // be the width of the list item, minus the space for the activity type
                      // graphic. I also wanted the text box to wrap, and to expand vertically if
                      // more space was needed. To get this to work, the MaxWidth property of the
                      // box must be set. Unfortunately, due to vagaries in my understanding of
                      // the WPF layout process, I don't know the "proper" way to do this so that
                      // it is based on the widths and margins of the controls involved. Hence the
                      // magic number 48, which is the width of the graphic, plus the margins,
                      // plus some fiddle-faddle.

                      Sigh :sigh: .

                      Software Zen: delete this;

                      O Offline
                      O Offline
                      obermd
                      wrote on last edited by
                      #16

                      This is actually a really good comment. It explains both the why and the what/how. I wouldn't call this a sin, but rather a reminder of why you did something the way you did.

                      1 Reply Last reply
                      0
                      • G Gary Wheeler

                        I just came across the following comment in some code I need to modify that was written in 2008:

                        // This is an ugly little hack. The effect I wanted was for the text box to
                        // be the width of the list item, minus the space for the activity type
                        // graphic. I also wanted the text box to wrap, and to expand vertically if
                        // more space was needed. To get this to work, the MaxWidth property of the
                        // box must be set. Unfortunately, due to vagaries in my understanding of
                        // the WPF layout process, I don't know the "proper" way to do this so that
                        // it is based on the widths and margins of the controls involved. Hence the
                        // magic number 48, which is the width of the graphic, plus the margins,
                        // plus some fiddle-faddle.

                        Sigh :sigh: .

                        Software Zen: delete this;

                        J Offline
                        J Offline
                        jmaida
                        wrote on last edited by
                        #17

                        Allman almost all the time.

                        "A little time, a little trouble, your better day" Badfinger

                        1 Reply Last reply
                        0
                        • G Gary Wheeler

                          I just came across the following comment in some code I need to modify that was written in 2008:

                          // This is an ugly little hack. The effect I wanted was for the text box to
                          // be the width of the list item, minus the space for the activity type
                          // graphic. I also wanted the text box to wrap, and to expand vertically if
                          // more space was needed. To get this to work, the MaxWidth property of the
                          // box must be set. Unfortunately, due to vagaries in my understanding of
                          // the WPF layout process, I don't know the "proper" way to do this so that
                          // it is based on the widths and margins of the controls involved. Hence the
                          // magic number 48, which is the width of the graphic, plus the margins,
                          // plus some fiddle-faddle.

                          Sigh :sigh: .

                          Software Zen: delete this;

                          C Offline
                          C Offline
                          CPallini
                          wrote on last edited by
                          #18

                          Well, that is a pretty informative and honest comment.

                          "In testa che avete, Signor di Ceprano?" -- Rigoletto

                          1 Reply Last reply
                          0
                          • G Gary Wheeler

                            jeron1 wrote:

                            K&R bracing

                            Everyone knows that Allman bracing is The One True Way.

                            Software Zen: delete this;

                            pkfoxP Offline
                            pkfoxP Offline
                            pkfox
                            wrote on last edited by
                            #19

                            I'd never heard of Allman bracing but having looked it up it's what I use in C and C#

                            In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP

                            T N 2 Replies Last reply
                            0
                            • pkfoxP pkfox

                              I'd never heard of Allman bracing but having looked it up it's what I use in C and C#

                              In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP

                              T Offline
                              T Offline
                              theoldfool
                              wrote on last edited by
                              #20

                              +1

                              >64 It’s weird being the same age as old people. Live every day like it is your last; one day, it will be.

                              1 Reply Last reply
                              0
                              • H honey the codewitch

                                You can do that with VS Code as well. It's a bit fiddly to change the C/C++ bracing and indent styles, but nothing a little google fu can't clear up. Then you just hit "Format Document" and bob's your uncle. I guess since I'm used to using different case styles for different languages, it's not as much of a stretch for me to adapt to different bracing? For me, C and C++ just seem more "natural" in K&R and C# just seems more natural to me in Allman. Feel and flow for me - the final form is just easier for me if I do it this way. I don't know WHY C# would be different than C or C++ for me that way, except exposure. I'm so used to seeing Allman C# and K&R C/C++ that it's familiar to me. That must be it, I think.

                                Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                                G Offline
                                G Offline
                                Gary R Wheeler
                                wrote on last edited by
                                #21

                                Ain't it wonderful how it can work either way, and the machine doesn't care? Makes you wonder how The Brace Wars ever got started...

                                Software Zen: delete this;

                                N 1 Reply Last reply
                                0
                                • G Gary Wheeler

                                  I just came across the following comment in some code I need to modify that was written in 2008:

                                  // This is an ugly little hack. The effect I wanted was for the text box to
                                  // be the width of the list item, minus the space for the activity type
                                  // graphic. I also wanted the text box to wrap, and to expand vertically if
                                  // more space was needed. To get this to work, the MaxWidth property of the
                                  // box must be set. Unfortunately, due to vagaries in my understanding of
                                  // the WPF layout process, I don't know the "proper" way to do this so that
                                  // it is based on the widths and margins of the controls involved. Hence the
                                  // magic number 48, which is the width of the graphic, plus the margins,
                                  // plus some fiddle-faddle.

                                  Sigh :sigh: .

                                  Software Zen: delete this;

                                  P Offline
                                  P Offline
                                  Peter Kelley 2021
                                  wrote on last edited by
                                  #22

                                  I say that's just fine! It reflects the exasperation and defeated feeling in the face of deadlines and "just get it done!" pressure. Personally I might have written more concisely something like "I had to put *SOMETHING* here so I pulled this number 48 out of thin air. Gotta move on from this!". :-D

                                  G 1 Reply Last reply
                                  0
                                  • P Peter Kelley 2021

                                    I say that's just fine! It reflects the exasperation and defeated feeling in the face of deadlines and "just get it done!" pressure. Personally I might have written more concisely something like "I had to put *SOMETHING* here so I pulled this number 48 out of thin air. Gotta move on from this!". :-D

                                    G Offline
                                    G Offline
                                    Gary Wheeler
                                    wrote on last edited by
                                    #23

                                    My long-winded explanation is there to provide a trail of breadcrumbs for my future self, on the off chance I come back to this in the 3.75 years left until retirement. 3.7499... 3.7498... 3.7497...

                                    Software Zen: delete this;

                                    1 Reply Last reply
                                    0
                                    • G Gary R Wheeler

                                      Ain't it wonderful how it can work either way, and the machine doesn't care? Makes you wonder how The Brace Wars ever got started...

                                      Software Zen: delete this;

                                      N Offline
                                      N Offline
                                      Nelek
                                      wrote on last edited by
                                      #24

                                      There are more serious wars started for less... :doh: :sigh:

                                      M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

                                      1 Reply Last reply
                                      0
                                      • pkfoxP pkfox

                                        I'd never heard of Allman bracing but having looked it up it's what I use in C and C#

                                        In a closed society where everybody's guilty, the only crime is getting caught. In a world of thieves, the only final sin is stupidity. - Hunter S Thompson - RIP

                                        N Offline
                                        N Offline
                                        Nelek
                                        wrote on last edited by
                                        #25

                                        +2 (I use it in everything that I start, if not.. .I try to stick with what is already being used)

                                        M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

                                        1 Reply Last reply
                                        0
                                        • G Gary Wheeler

                                          I just came across the following comment in some code I need to modify that was written in 2008:

                                          // This is an ugly little hack. The effect I wanted was for the text box to
                                          // be the width of the list item, minus the space for the activity type
                                          // graphic. I also wanted the text box to wrap, and to expand vertically if
                                          // more space was needed. To get this to work, the MaxWidth property of the
                                          // box must be set. Unfortunately, due to vagaries in my understanding of
                                          // the WPF layout process, I don't know the "proper" way to do this so that
                                          // it is based on the widths and margins of the controls involved. Hence the
                                          // magic number 48, which is the width of the graphic, plus the margins,
                                          // plus some fiddle-faddle.

                                          Sigh :sigh: .

                                          Software Zen: delete this;

                                          H Offline
                                          H Offline
                                          honey the codewitch
                                          wrote on last edited by
                                          #26

                                          I've got this weird problem where because I think in code, my code comments can sometimes look like commented out code. :laugh: Sometimes in my open source projects I'll bury a comment deep in the source code to see if anyone is paying attention:

                                          // Lee Harvey Oswald faked the moon landing

                                          Check out my IoT graphics library here: https://honeythecodewitch.com/gfx And my IoT UI/User Experience library here: https://honeythecodewitch.com/uix

                                          G 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