- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
try {
if (something) {
throw new MyGotoException();
}
DoSomethingElse();
}
catch (MyGotoException) {
}
DoGotoBlock();
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+152
try {
if (something) {
throw new MyGotoException();
}
DoSomethingElse();
}
catch (MyGotoException) {
}
DoGotoBlock();
Очень хитрый вариант реализации схемы goto.
+147
if (chk.Checked)
{
foreach (BV.Star.BLL.PersonGroups.PersonGroup trainee in trainees)
{
if (trainee.TraineeID.ToString() == gvwTrainees.DataKeys[gvwTrainees.PageIndex == 0 ? gvr.DataItemIndex : (gvr.DataItemIndex % gvwTrainees.PageSize)].Value.ToString())
goto Next;
}
InsertTraineeIntoGroup(Int32.Parse(ddlGroups.SelectedValue),
Int32.Parse(gvwTrainees.DataKeys[gvwTrainees.PageIndex == 0 ? gvr.DataItemIndex : (gvr.DataItemIndex % gvwTrainees.PageSize)].Value.ToString()),
false, DateTime.MaxValue,
"");
Next: ;
}
И снова на сцене - goto!
+143.1
if (((HttpContext.Current.Profile as ProfileCommon).Role == "3") || ((HttpContext.Current.Profile as ProfileCommon).Role == "4"))
{
if (e.Item.Value == " Add New Trainee ")
e.Item.Enabled = false;
if (e.Item.Value == " Add New Group ")
e.Item.Enabled = false;
if (e.Item.Value == " Audit Log ")
e.Item.Enabled = false;
if (e.Item.Value == " Manage Holidays ")
e.Item.Enabled = false;
}
if ( (( HttpContext.Current.Profile as ProfileCommon).Role != "0") && (( HttpContext.Current.Profile as ProfileCommon).Role != "") )
{
if (e.Item.Value == " Manage Users ")
e.Item.Enabled = false;
if (e.Item.Value == " Manage Courses ")
e.Item.Enabled = false;
if (e.Item.Value == " Audit Log ")
e.Item.Enabled = false;
}
if (((HttpContext.Current.Profile as ProfileCommon).Role == "") ||
((HttpContext.Current.Profile as ProfileCommon).Role == "0") ||
((HttpContext.Current.Profile as ProfileCommon).Role == "1") ||
((HttpContext.Current.Profile as ProfileCommon).Role == "2"))
{
if (e.Item.Value == " Holidays ")
e.Item.Enabled = false;
}
Новое место работы. Новые порции говнокода.
Это классика - no comments...
+145
/// <summary>
/// Child border.
/// </summary>
private Border childBorder;
Я бы никогда без комментария не догадался, зачем же это поле
+958.8
idString.Length == Guid.NewGuid().ToString.Length()
Самый имхо индусский (см. лукмор) код проверить что строка это Guid
+112.5
public void Log(string pSource, string pMessage, EventLogEntryType pEntryType) {
try {
if (!EventLog.SourceExists(pSource)) {
EventLog.CreateEventSource(pSource, "Application");
}
EventLog.WriteEntry(pSource, pMessage, pEntryType);
}
catch (Exception _ex) {
Log("", _ex.ToString(), EventLogEntryType.Error);
}
}
Пишем в лог - постоянно...
Автор находки: http://ayende.com/Blog/archive/2009/03/19/how-not-to-write-a-logger.aspx
+135.9
String[] days = new String[7];
for( int i = 0; i < 7; i++ ) {
switch(i) {
default:
case 0:
days[i] = "Monday";
break;
case 1:
days[i] = "Tuesday";
break;
case 2:
days[i] = "Wednesday";
break;
case 3:
days[i] = "Thursday";
break;
case 4:
days[i] = "Friday";
break;
case 5:
days[i] = "Saturday";
break;
case 6:
days[i] = "Sunday";
break;
}
}
Боян, наверное, но все-таки...
+119
private string StripDuplicateSpaces(string data)
{
bool flag = false;
do
{
if (data.IndexOf(" ") != -1)
{
data = data.Replace(" ", " ");
}
}
while (!flag);
return data.Trim();
}
private string TrimNewLines(string s)
{
return s;
}
за это ещё и денег просят :)
+150
[Serializable]
public class Key
{
public Key(long id, string code)
{
m_Id = id;
m_Code = code;
}
public Key(long id) : this(id, null)
{
}
public Key(string code) : this(0, code)
{
}
public Key() : this(0, null)
{
}
public long getId()
{
return (m_Id);
}
public long m_Id;
public string getCode()
{
return (m_Code);
}
public string m_Code;
public static string ToString(Key k)
{
return ((k == null) ? "(null)" : k.ToString());
}
}
+150
public const char ExpMonthSeparator = ':';
protected void BindPager()
{
var colon = string.Format("{0}", ExpMonthSeparator);
/* And some lines for refactor */
}
Фикся очередную багу наткнулся на такую прелесть