20081218

Simplify Simplify Simplify

Here is the code as found ::
private string FormatTime(object DateTimeValue)
{
string result = " ";
if (DateTimeValue != null)
{
DateTime dt = DateTime.Parse(DateTimeValue.ToString());
if (dt.Hour < 10)
result = FILLER_NUMBER + dt.Hour.ToString() + ":";
else
result = dt.Hour.ToString() + ":";

if (dt.Minute < 10)
result += (FILLER_NUMBER + dt.Minute.ToString() + ":");
else
result += (dt.Minute.ToString() + ":");

if (dt.Second < 10)
result += (FILLER_NUMBER + dt.Second.ToString());
else
result += dt.Second.ToString();
}

return result;
}


Here is the refactored version::

return DateTime.Parse(DateTimeValue.ToString()).ToString("HH:mm:ss");

20081212

The wheels of the object go round and round

Notice that if dsSTData were null you will allocate it, but not use it to look up the ThingyMin :)

public int ThingyMin
{
get
{
int _ThingyMin = 0;
if (dsSTData == null)
{
this.dsSTData = ONAME.ProdName.Common.Business.CONAMESystemDataList.STs;
}
else
{
foreach (System.Data.DataRow row in sSTData.Tables[this.DEFAULT_TABLE].Rows)
{
if (Convert.ToInt32(row[0]) == this._STID)
{
_ThingyMin = int.Parse(row[OllCommon.COL_THINGY_MIN].ToString());
break;
}
}
}
return _ThingyMin;
}
}

20081210

How to ruin a set of data

From my bud. Not strictly SQL but close enough. He would like to know:

I'm not asking a lot. I just would rather see
"if (this.Order.IsPacked)"


instead of
"if (
this._DataSet.Tables[OrderCommon.TBL_ORDER].Rows[OrderCommon.DEFAULT_ROW][OrderCommon.COL_IS_PACKED] == DBConst.DBNull)"

License & copyright

Creative Commons License
StinkySQL weblog and any related pages, including the weblog's archives are licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.