|
Nothing wrong with that, but maybe use an alias instead.
Would you prefer:
class MyTypeCollection : Dictionary<string, List<Tuple<string, DateTime, List<MyType>>>> {}
|
|
|
|
|
If todayPos.Instrument.InstrumentTypeID <> TYPE_FIXEDINCOME OrElse todayPos.Instrument Is Nothing Then
Continue For
End If
It works so much better if you do the defensive bit before the OrElse...
|
|
|
|
|
Oh wait, that guy forgot another null check:
If todayPos.Instrument.InstrumentTypeID <> TYPE_FIXEDINCOME OrElse todayPos.Instrument Is Nothing OrElse todayPos Is Nothing Then
Continue For
End If Hope that helps with the ugly "reference not set to an object" exception you faced.
|
|
|
|
|
You must respect the putting of the cart before the horse!
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
bool orphan = false;
if (intJobCategory < 0 || intJobType < 0)
{
orphan = true;
}
if (orphan)
{
string message = "orphan detected intJobCategoryJobTypeID=" + intId.ToString();
this.state.Status = message;
}
else
{
...
}
And just to clarify, that bool is never used again...
|
|
|
|
|
Some people prefer to spell it out rather than jam it all into a single line.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I agree it's ugly, could it be that orphan was used in other places at some point?
"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
|
|
|
|
|
That's what I thought, maybe the variable was originally used elsewhere but that code deleted and this not tidied up. Also compiler optimisation would probably fix this code anyway.
|
|
|
|
|
That's what I hoped but I checked through the revision history and no sign of it being used.
|
|
|
|
|
Debug purposes or planned mechanics never introduced. It happens.
GCS d--- s-/++ a- C++++ U+++ P- L- E-- W++ N++ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t++ 5? X R++ tv-- b+ DI+++ D++ G e++>+++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
If you think 'goto' is evil, try writing an Assembly program without JMP. -- TNCaver
When I was six, there were no ones and zeroes - only zeroes. And not all of them worked. -- Ravi Bhavnani
|
|
|
|
|
You must have just gotten a job in my organization.
|
|
|
|
|
Ah, when the initial commit from psudocode doesn't ever cleaned up. Good days.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
How ugly that code is with its inconsistent naming! Tell those poor code monkeys to clean it up:
it must be boolOrphan instead of orphan , and strMessage instead of message !
How come it they forgot half of their VB6 wisdom?
|
|
|
|
|
Hungarian Notation:
For when intellisense just seems too hard.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
'False' Hungarian uses the prefixes to describe types. Instead, the prefixes were intended to describe the usage of the variable. Remember such things as 'lpstr', a long pinter to a string terminated by zero? Can Intellisense do that as well?
The language is JavaScript. that of Mordor, which I will not utter here
This is Javascript. If you put big wheels and a racing stripe on a golf cart, it's still a f***ing golf cart.
"I don't know, extraterrestrial?"
"You mean like from space?"
"No, from Canada."
If software development were a circus, we would all be the clowns.
|
|
|
|
|
An absolutely fair point that unfortunately does not describe the usage I see in web applications.
I apologize for maligning Hungarian Notation. I may have simply lost my mind after seeing lblLabel one too many times.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
That's why I still like oldschool machine code. You can't do very much wrong with hexadecimal.
The language is JavaScript. that of Mordor, which I will not utter here
This is Javascript. If you put big wheels and a racing stripe on a golf cart, it's still a f***ing golf cart.
"I don't know, extraterrestrial?"
"You mean like from space?"
"No, from Canada."
If software development were a circus, we would all be the clowns.
|
|
|
|
|
if (orphan)
{
string message = "orphan detected intJobCategoryJobTypeID=" + intId.ToString();
this.state.Status = message;
}
if (orphan)
{
string message = "";
message = "orphan detected intJobCategoryJobTypeID=";
message += intId.ToString();
this.state.Status = message;
}
Of course concatenating strings is not very productive, so you could create a Stringbuilder, concatenate the pieces, create a string with the toString method and set that string to the Status variable.
Forgive the person who wrote that, he's just a padawan learner
|
|
|
|
|
A stringbuilder to concatenate two strings is overkill, you could just use string.Concat, it has the same benefits of the StringBuilder without the overhead of creating an object and without any risk that memory needs reallocated multiple times. You should only use stringbuilder if the size of the resultant text can't easily be known, or if you know you are going to do a lot of concatenation.
|
|
|
|
|
it was a quick joke, not a serious reply.
|
|
|
|
|
Code iz serius bizness!!1
|
|
|
|
|
|
Control docking and anchoring are well understood by everybody and we all know that the two techniques are mutally exclusive. The help pages says something like "Only one can be set at a time, and the last one set takes precedence".
I've always believed what I'm told by my elders and betters and was certain that code like the following would create an anchored control.
FancyControl fc = new FancyControl();
fc.Anchor = AnchorStyles.Top | AnchorStyles.Left;
SomePanel.Controls.Add(fc);
My FancyControl would typically be used fully docked and the constructor helpfully presets that condition. On the very rare occasion it should be anchored then just assign a value as shown.
Why oh why then, did the control remained dicked?
FancyControl fc = new FancyControl();
Debug.Print("Dock: {0} Anchor: {1}", fc.Dock, fc.Anchor);
fc.Anchor = AnchorStyles.Top | AnchorStyles.Left;
SomePanel.Controls.Add(fc);
On reading the Anchor property all became clear as the value was already Top|Left. Perhaps the Anchor property ignores redundant assignments? Of course it does and a delve into the published reference source confirms this. Search for DefaultLayout.SetAnchor in Reference Source[^] if you are interested.
The final solution for the simple task of setting the control's anchor property is
FancyControl fc = new FancyControl();
fc.Dock = DockStyle.None;
SomePanel.Controls.Add(fc);
OK I should have included the statement fc.Anchor = AnchorStyles.Top | AnchorStyles.Left; after undocking but it's redundant!
AlanN
aka Alan "2f hours debugging" N
|
|
|
|
|
Alan N wrote: did the control remained dicked?
Is that gender-specific control property?
Marc
|
|
|
|
|
No, having a dick does not imply gender at all these days.
#SupportHeForShe
Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
|
|
|
|