My sins return to haunt me
-
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;
Gary Wheeler wrote:
magic number 48
Isn't it 42?
-
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;
-
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;
-
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;
-
jeron1 wrote:
K&R bracing
Everyone knows that Allman bracing is The One True Way.
Software Zen:
delete this;
-
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
+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.
-
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
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;
-
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;
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
-
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
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;
-
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;
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.
-
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
+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.
-
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;
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
-
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
honey the codewitch wrote:
because I think in code, my code comments can sometimes look like commented out code
That makes a lot of sense, since you are a team of one. It's a good example of 'consider your audience', where your future self will be reading the comment. I've found my commenting changing the last couple of years. I'm going to retire in less than four years, so some poor schmuck person is going to be taking this over. Our code lives for a long time (we have active code over 20 years old), so a lot of it will still be around. I'm adding more explanatory comments than I used to.
honey the codewitch wrote:
// Lee Harvey Oswald faked the moon landing
Software Zen:
delete this;
-
I am not sure, given all that explanation, it it still qualifies as a magic number. Even the word 'sin' in heavy handed here, it's not like K&R bracing... runs and hides :laugh:
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
I despise K&R bracing. I have ALWAYS used Allman (for the last 45 years), and at work, we're using K&R (apparently the go-to bracing used in javashit). I hate it. It's unnatural. Curious note: I never knew the bracing styles had names. I always referred to them as "the way I do it", and "not the way I do it".
".45 ACP - because shooting twice is just silly" - JSOP, 2010
-----
You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
-----
When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013