I didn't it's not my project. My colleague was traumatised by this and many other code-crimes in the project, I'm hoping he'll recover soon :laugh:
Mardy Git
Posts
-
If in doubt: cast, cast and cast again -
If in doubt: cast, cast and cast againMy colleague found this and other horrors in a newish project. Bearing in mind that "Id" is a nullable int and result.ID is a regular int, who in their right mind would do this (object and function names have been changed to protect the incompetent):
protected Thing populateThing(DataRow dr)
{
Thing result = new Thing();
result.Id = int.Parse(dr["Id"].ToString());BTW, note no handling of the case when "Id" is DBNULL. You can stop laughing now.
-
goto statementRemember
goto
is a four letter word and bad things will happen if you use it...
-
Religious question - MVC benefits vs ASP.NET?A couple of gigs ago, we replaced an admittedly bad ASP.Net site with an MVC4/Razor site. It was a handful of SPAs using partial views and Ajax post-backs. Blindingly fast and a much better user experience - go for it!
-
Religious question - MVC benefits vs ASP.NET?A couple of gigs ago, we replaced an admittedly bad ASP.Net site with an MVC4/Razor site. It was a handful of SPAs using partial views and Ajax post-backs. Blindingly fast and a much better user experience - go for it!
-
Anyone see the problem here?My colleague found this in some production code for a very well known company. I'm wondering what horrors we'll exhume next.
-
Anyone see the problem here?public class ErrorLogging
{
/// <summary>
/// Insert into error log
/// </summary>
/// <param name="errorMessage"></param>
/// <param name="errorTrace"></param>
/// <param name="errorLocation"></param>
public void insertErrorLog(string errorMessage, string errorTrace, string location)
{
int? errorID = 0;
XXXXX_DataAccess.common.XXXXX_CMSTableAdapters.XXXXXCMS_TA ta = new common.XXXXX_CMSTableAdapters.XXXXXCMS_TA();try { ta.usp\_ErrorLogInsert(ref errorID, errorMessage, errorTrace, location); } catch (Exception ex) { ta.usp\_ErrorLogInsert(ref errorID, ex.Message, ex.StackTrace, "insertErrorLog - XXXXX\_DataAccess"); } } }