|
Hope they don't work with you anymore.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
If the 'do something with strValue' is the same in all six cases, it obviously makes sense to pull that out of the case. As for the broader question of whether to append discretely-counted zeros, it's obviously ugly but I believe the code will only generate one new string when it's called. Most other approaches I'm familiar with would generate two new strings.
|
|
|
|
|
The System.String class has a nice little pair of PadLeft()/PadRight() functions. All it needs is the character to use for padding, and the final length the string needs to be, so that whole switch could be replaced with
const int FIXED_LENGTH = 6;
str = str->PadLeft('0', FIXED_LENGTH);
Dybs
|
|
|
|
|
I once worked on an application where one of the developers fulfilled the requirement of commenting his code by putting at the top of each method:
Well, thank you Captain Obvious!
:josh:
My WPF Blog[ ^]
All of life is just a big rambling blog post.
|
|
|
|
|
hahaha that sounds great, what comment system do you use, i have used doxygen with some sucess but it becomes a little tiresome after a while
"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius and a lot of courage to move in the opposite direction." -Albert Einstein
|
|
|
|
|
Josh Smith wrote: // Enforce Method Contract
Possibly a placeholder for later elaboration (never done, of course! )
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
I worked with a chap that did a retro fit of function headers on files where they'd largely been left out. The functions themselves were meaningfully named and internally well commented. Unfortunately he decided that he didn't have time to write descriptive text for all of them, so just put TODO: Add function comment. This was a real pain, all of our TODO: Fix nasty bug and TODO: Finish writing this important piece of code before release got buried beneath approximately a thousand worthless TODOs.
|
|
|
|
|
I have seen code where the standard practice was to leave in the // TODO: Add constructor logic here that the compiler puts in automatically. The folk that did it never saw a problem with doing that because they didn't use the Task list. I found it to be a problem as soon as I put in a useful TODO and it was overwhelmed my hundreds of pointless TODOs.
Bill W
|
|
|
|
|
That's good.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
That sounds reasonable to me. I'm pleased to see that he thinks the contract is so important. Or is this some form of bizarre Arnold Schwarzenegger motivational speaking type of thing. Try saying it in an Austrian accent, and it really works.
|
|
|
|
|
Pete O'Hanlon wrote: Try saying it in an Austrian accent, and it really works
:josh:
My WPF Blog[ ^]
All of life is just a big rambling blog post.
|
|
|
|
|
You've got a point there. One can imagine Arnie busting out the one-liner "contract enforced" after dispatching some poor sap.
Steve
|
|
|
|
|
Stephen Hewitt wrote: One can imagine Arnie busting out the one-liner "contract enforced" after dispatching some poor sap.
That's how he runs California.
Faith is a fine invention
For gentlemen who see;
But microscopes are prudent
In an emergency!
-Emily Dickinson
|
|
|
|
|
Hi,
I once saw in a real piece of code the following fragment! Nice name, don't you think?
{
boolean e0x0301=false;
.
.
.
if (!e0x0301) { ... }
}
modified 7-Mar-17 16:39pm.
|
|
|
|
|
Bill, searching frenetically in the pile of paper on his desk while hitting F5.
Bill: "Oh god, I keep losing this post-it on which I note the address of the array cell that does not get filled properly"
James, sitting next to him, smiling :" Why don't you rename a variable after it ?..."
Bill:" Oh yes, good idea, I suppose I'll remove it later in the production code."
|
|
|
|
|
Nice
modified 7-Mar-17 16:38pm.
|
|
|
|
|
What's really scary is that I'm a 'Bill', well a William, and my old boss was a James.
The stupidity of the 'James' suggestion reminded me of him. (I must find out if he's sober yet; it has been seven years)
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Looks like an obfuscated class have been decompiled anyway...
|
|
|
|
|
haha that is great
the only place u should see hex numbers is Hardware.h imho
|
|
|
|
|
I will confess to having used hex-ish variable names in code for certain hardware ports which didn't have standardized names. I've also used hex-ish defined constants for colors which needed to be remappable to different hardware (an NTSC system used $1x for gold, $4x for red, $8x for blue, $Cx for green, and $Fx for green-yellow; PAL systems mapped the colors completely differently). Although there are defined names for colors, I find it much easier to know that $3x is an almost red orange than to remember whether "ORANGE" refers to $2x or $3x.
Those things having been said, the code here looks like it may have been obfuscated.
|
|
|
|
|
Ummm, no
I'm very fond of adding flag words to objects instead of doing something horrible like adding countless bool members. Usually they are an enumerated type and defining them in anything than hex is awkward. Like this:
[flags]
public enum D_SOMEFLAGS : ulong
{
NONE = 0x0000000000000000,
VALIDATED = 0x0000000000000001,
CHANGED = 0x0000000000000002,
}
But I agree that hex notation should only be used in variable names on rare occasions.
A while ago he asked me what he should have printed on my business cards. I said 'Wizard'.
I read books which nobody else understand. Then I do something which nobody understands. After that the computer does something which nobody understands. When asked, I say things about the results which nobody understand. But everybody expects miracles from me on a regular basis. Looks to me like the classical definition of a wizard.
|
|
|
|
|
well we arent really in disagrement because when using this you will never see the values set only the symbols which is fine, good practise for saving memory infact.
the conatations i was implying was that hex numbers should be out of the way.
|
|
|
|
|
Yikes. That looks like something to do on a project when one is about to leave a company [evil grin]...
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Looks like this variable determines whether an object has a particular set of flags. If there would be, let say, 10 flags, then a 'meaningful' name would have to be "IsFlag1AndFlag2AndFlag3And....AndFlag10AndNothingElse = false "
So, for the author of a flag's enumeration this is just a short form of the above.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
A few posts above I also commented on flags.
[flags]
public enum D_SOMEFLAGS : ulong
{
NONE = 0x0000000000000000,
VALIDATED = 0x0000000000000001,
CHANGED = 0x0000000000000002,
}
would it not be better (using my example there) to add something like
...
CHANGED_AND_VALIDATED = 0x0000000000000003;
...
to the enumeration?
A while ago he asked me what he should have printed on my business cards. I said 'Wizard'.
I read books which nobody else understand. Then I do something which nobody understands. After that the computer does something which nobody understands. When asked, I say things about the results which nobody understand. But everybody expects miracles from me on a regular basis. Looks to me like the classical definition of a wizard.
|
|
|
|