|
if (a >= 1 && a <= 4)
DoSomething(a);
is a better option than a switch I think .
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.
|
|
|
|
|
gajatko wrote: if (a >= 1 && a <= 4) DoSomething(a);
is a better option than a switch I think .
Hmmmm...in this case, yes
|
|
|
|
|
And that's why your previous post got voted down.
|
|
|
|
|
VentsyV wrote: And that's why your previous post got voted down.
once I start caring, I might start paying attention to the scores.
|
|
|
|
|
That post was for Paul Conrad's benefit really.
|
|
|
|
|
VentsyV wrote: That post was for Paul Conrad's benefit really.
A pity, then, that it appeared as a reply to MY post. I am an INNOCENT BYSTANDER!!
|
|
|
|
|
Ah. Don't worry about it. You see, the compiler takes a look at this and works out the redundancy. In fact, the redundancy notices should be on their desks by the time the link cycle has completed.
|
|
|
|
|
|
That is almost beautiful in it's inelegance! It is hard to come up with something convoluted and still have code that looks like the person writing it didn't try hard to make it as convoluted as possible...
|
|
|
|
|
if(a==1 || a==2 || a==3 || a==4)<br />
{<br />
if(a==1)<br />
DoSomething(1);<br />
else if(a==2)<br />
DoSomething(2);<br />
else if(a==3)<br />
DoSomething(3);<br />
else if(a==4)<br />
DoSomething(4);<br />
}
DoSomething(a);
|
|
|
|
|
big LOL, maybe this is how the runtime actually works
|
|
|
|
|
Hi. Background: Co-Worker, (Female <- not biased, just stating the fact), Qualification: Architect...
(btw, this is all C# VS2008 code, I swear)
Ok, one for the count:
public static bool NameExists (string name)
{
bool exists = false;
int i = 0;
while ((i < someListContainingNames.Count) && (exists == false))
{
if (someListContainingNames[i] == filename)
{
exists = true;
}
i++;
}
return exists;
}
Please see if you can read this... (Original code kept):
else if ( ((isEXEDLL == true) || (isEXEConfig == true))
&& ((staysTheSameEXEDLL == false) || (EXEDLLPathExistsSoCanProcess == true))
)
{
if ( ((isEXEDLL == true) || (isEXEConfig == true))
&& (staysTheSameEXEDLL == false)
)
{
if (canCopy.DoCopy == true)
{
Spot the redundency (Regex's left out):
string str = "";
string str2 = "";
Regex regex1 = new Regex(regex1String, RegexOptions.IgnoreCase);
Regex regex2 = new Regex(regex2String, RegexOptions.IgnoreCase);
Regex regex3 = new Regex(regex3String, RegexOptions.IgnoreCase);
Regex regex4 = new Regex(regex4String, RegexOptions.IgnoreCase);
if (regex1.IsMatch(filename))
{
str = regex1.Match(filename).Groups["code"].Value.ToUpper();
str2 = regex1.Match(filename).Groups["type"].Value.ToUpper();
}
else if (regex2.IsMatch(filename))
{
str = regex2.Match(filename).Groups["code"].Value.ToUpper();
str2 = regex2.Match(filename).Groups["type"].Value.ToUpper();
}
else if (regex3.IsMatch(filename))
{
str = regex3.Match(filename).Groups["code"].Value.ToUpper();
str2 = regex3.Match(filename).Groups["type"].Value.ToUpper();
}
else if (regex4.IsMatch(filename))
{
str = regex4.Match(filename).Groups["code"].Value.ToUpper();
str2 = regex4.Match(filename).Groups["type"].Value.ToUpper();
}
else
{
str = "";
str2 = "";
}
if ( (regex1.IsMatch(filename))
|| (regex2.IsMatch(filename))
|| (regex3.IsMatch(filename))
|| (regex4.IsMatch(filename))
)
{
Didn't get that one? Try this one:
if (dr.GetValue(dr.GetOrdinal("Copy")).ToString().Trim() == "1")
copyChecked = true;
else
copyChecked = false;
Ok, now I'm not pedantic, this I can promise you, but when you come across something like this little gem... (Only method name and class type changed...)
public static bool MethodName(ObjectWithBoolean objectThatHasBool)
{
if (objectThatHasBool.booleanValue)
{
return false;
}
else
{
return true;
}
}
Last, but DEFINITELY not the least, here's a little sql query that my "collegue" wrote. See if you can spot the query:
StringBuilder queryString = new StringBuilder();
queryString.Append("IF EXISTS ");
queryString.Append("(SELECT ID ");
queryString.Append("FROM ");
queryString.Append("Table1 ");
queryString.Append("WHERE ID = ");
queryString.Append(id);
queryString.Append(") ");
queryString.Append("BEGIN ");
queryString.Append("UPDATE ");
queryString.Append("Table1 SET ");
queryString.Append("ComlumnValue1 = ");
queryString.Append("'");
queryString.Append(Value1);
queryString.Append("' ");
queryString.Append(", ComlumnValue2 = ");
queryString.Append(Value2);
queryString.Append(", ComlumnValue3 = ");
queryString.Append(Value3);
queryString.Append(" WHERE ID = ");
queryString.Append("'");
queryString.Append(id);
queryString.Append("' ");
queryString.Append("AND ");
queryString.Append("(ISNULL(ComlumnValue1,0) <> ");
queryString.Append("'");
queryString.Append(Value1);
queryString.Append("' ");
queryString.Append(" OR ");
queryString.Append("ISNULL(ComlumnValue2,0) <> ");
queryString.Append(Value2);
queryString.Append(" OR ");
queryString.Append("ISNULL(ComlumnValue3,0) <> ");
queryString.Append(Value3);
queryString.Append(") ");
queryString.Append(" END ");
queryString.Append("ELSE BEGIN declare @ID int ");
queryString.Append("exec ssl_GetTable1CallSeq 1, ");
queryString.Append("@ID OUTPUT ");
queryString.Append("IF ");
queryString.Append("NOT EXISTS(SELECT * FROM Table1 WHERE ID = ");
queryString.Append(id);
queryString.Append(") ");
queryString.Append("INSERT ");
queryString.Append("INTO Table1 (ID, Name, ");
queryString.Append("ComlumnValue1, ");
queryString.Append("ComlumnValue2, ");
queryString.Append("ComlumnValue3) ");
queryString.Append("VALUES ");
queryString.Append("(@ID, ");
queryString.Append("'");
queryString.Append(name);
queryString.Append("', ");
queryString.Append("'");
queryString.Append(Value1);
queryString.Append("', ");
queryString.Append(Value2);
queryString.Append(", ");
queryString.Append(Value3);
queryString.Append(" ) END ");
command.CommandText = queryString.ToString();
Thanks for listening to my little rant. Any comments very welcome,
|
|
|
|
|
No surprise: Architects are supposed to design buildings...
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]
|
|
|
|
|
adamsappel wrote: Female <- not biased, just stating the fact
Then why did you mention it?
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
|
Why not? If it was worth mentioning that the profession of the "developer" in question is, it's worth mentioning what the sex of the person is. Well done on nitpicking. Feminist pricks.
|
|
|
|
|
Race?
Age?
Country of origin?
Religion?
|
|
|
|
|
Race? 100m for people with no sense of direction.
Age? middle
Country of origin? Current thinking is North Africa, maybe Egypt, then humans slowly migrated across all the land mass.
Religion? Helps in the dark pit of night.
Does that help?
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Rsole
I still remember having to write your own code in FORTRAN rather than be a cut and paste merchant being pampered by colour coded Intellisense - ahh proper programming - those were the days
|
|
|
|
|
Such a nice quote. Seriously, I feel your pain.
PS: I'm not an "Rsole"
(PPS: is it still 'an' and not 'a' when using illegal abreviations, whilst being a little hipocritical with your quote?)
|
|
|
|
|
adamsappel wrote: PS: I'm not an "Rsole"
What, exactly, is an Rsole??
|
|
|
|
|
Say the first letter on it's own.
|
|
|
|
|
Jeez, is that the letter 'a'?
"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
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Pete O'Hanlon wrote: Say the first letter on it's own.
oK
|
|
|
|
|
adamsappel wrote: it's worth mentioning what the sex of the person is
Why? It doesn't have any bearing on the code.
adamsappel wrote: If it was worth mentioning that the profession of the "developer" in question is
That has a bearing on the code. The sex of the person doesn't.
adamsappel wrote: Feminist pricks.
You're just being a bigotted sexist pig, and people are rightly offended by such an obnoxious attitude.
|
|
|
|