|
Last time I tried to even check the site out, it was at a crawl.
|
|
|
|
|
Not a new horror, nonetheless something tells me this If statement may be redundant...
fileName = ""
If Len(fileName) = 0 Then
fileName = Left(DBEngine.Workspaces(0).Databases(0).Name, i) & "REF"
End If
|
|
|
|
|
Even the fileName = "" is redundant here.
|
|
|
|
|
Hmmm, tricky.
Give me a few hours and I'll get back to you on that one...
8)
|
|
|
|
|
Well, stating the obvious, it's quite likely that, either the coder didn't want to rely on code never being inserted between the initializer and guard, or, more likely, the coder added the initializer later, probably to test the guard.
Hey, you never know...
|
|
|
|
|
There may have been code between the initialiser and the if statement that has since been removed.
It might actually be a better piece of coding than you think. You always have the option of inserting some more code between the two and it might stand a chance of still working.
|
|
|
|
|
True, I would agree with you... He is testing for null. Having it in there is better than not having it in there.
"Program testing can be used to show the presence of bugs, but never to show their absence."
<< please vote!! >>
|
|
|
|
|
So the if statement is redundent...
Maybe the dude has got a resentment towards some tester maybe?
fileName is obviously a string which is a referenced type. If it wasn't initialized could of contained some garbage and length would of therefor been > 0.
However this is not the case... It is initialised and therefor redundent.
"Program testing can be used to show the presence of bugs, but never to show their absence."
<< please vote!! >>
|
|
|
|
|
I posted an example like this in the lounge a few months ago...
also found ASP code like this...
for each element in Request.form
if request.form("specificElement") <> "" then
someVar = request.form("specificElement")
...
[do some other stuff]
end if
next
It hurts both my eyes and my brain
|
|
|
|
|
We do not see the scope of fileName. Maybe another thread can change it's value
|
|
|
|
|
then the code would be incorrect even with the test for zero length
|
|
|
|
|
incorrect - yes, I'm not talking about sync-ing threads. My point was in that case code would not be "Testing the obvious..."
|
|
|
|
|
|
ugh. if only we all understood how static works... and perhaps naming conventions... hmm, i guess understanding when to apply the word "static" to a class might also be helpful... i don't even care about the bad use of List<SqlParameter>.
Oh and don't worry, there were comments for the functions, the class, the property, and of course i didn't remove the one inside the constructor...
public class IDataAccesslayer
{
private static SqlConnection conn = new SqlConnection(WebConfigurationManager.ConnectionStrings["connStr"].ToString());
public IDataAccesslayer()
{
}
public static void ExecuteNoReturn(String spName, List<SqlParameter> parms)
{
try
{
conn.Open();
SqlCommand cmd = new SqlCommand(spName, conn);
cmd.CommandType = CommandType.StoredProcedure;
foreach (SqlParameter parm in parms)
{
cmd.Parameters.Add(parm);
}
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
throw (ex);
}
finally
{
if (conn.State == ConnectionState.Open)
conn.Close();
}
}
public static DataSet ExecuteReturnDataSet(String spName, List<SqlParameter> parms)
{
}
}
|
|
|
|
|
Don't forget the abomination that is
throw (ex);
|
|
|
|
|
Gaaah!!!
throw new Stone();
|
|
|
|
|
I also like:
WebConfigurationManager.ConnectionStrings("connStr").ToString()
Maybe he wasn't confident enough that WebConfigurationManager.ConnectionStrings("connStr") would return a string.
Maybe he should be sure with:
WebConfigurationManager.ConnectionStrings("connStr").ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString().ToString()
|
|
|
|
|
I wonder... What moves a man to type an "I" at the begining of a bad named DataAccesslayer class for naming a static class which is not static, and even has a default constructor to construct absolutely nothing?
|
|
|
|
|
Salary aayi hain.... Salary aayi hain ... bade dine ke baad ham kangalo ke paas thodi haryali aayi hain
For any question : http://pranayamr.blogspot.com/
vote my article :
http://www.codeproject.com/KB/cs/LINQ_Visual_Representatio.aspx
http://www.codeproject.com/KB/aspnet/jQuery_To_WCF.aspx
|
|
|
|
|
A translation would be nice.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
I disagree. Even before knowing what it means, I doubt it has any value.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Perhaps. I tried Google translator, but it couldn't handle it.
Oh, well. It might be something amusing, but it doesn't belong in the forum for coding horrors.
Just because the code works, it doesn't mean that it is good code.
|
|
|
|
|
Not at all amusing. I can translate it for you but it is not at all worth it. Also doesn't belong to any forums.
|
|
|
|
|
The salary has arrived,
the day has came, my salary has arrived...
after long hard working days,
in the hands of moneyless, the greenery has arrived...
---------------
I hope this helps, to non-hindi speaking people.
|
|
|
|
|
I think you should have posted this in the General Indian Topics forum...
I wasn't, now I am, then I won't be anymore.
|
|
|
|