- 1
- 2
- 3
if (!"list".equals(message.getString("response"))) {
throw new IOException("Expected list response but got: " + message.toString());
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+155
if (!"list".equals(message.getString("response"))) {
throw new IOException("Expected list response but got: " + message.toString());
}
принятие ответа от сервера
+139.8
public enum TimePeriod {
NONE,
DAILY,
WEEKLY,
MONTHLY,
YEARLY;
public static TimePeriod getTimePeriod(String periodStr) {
if (null == periodStr) {
return null;
}
if (0 == periodStr.length()) {
return NONE;
}
if (0 == periodStr.compareToIgnoreCase("daily")) {
return DAILY;
}
if (0 == periodStr.compareToIgnoreCase("weekly")) {
return WEEKLY;
}
if (0 == periodStr.compareToIgnoreCase("monthly")) {
return MONTHLY;
}
if (0 == periodStr.compareToIgnoreCase("yearly")) {
return YEARLY;
}
return null;
}
}
а правильно будет так
public static TimePeriod parse(String type) {
return valueOf(type.toUpperCase());
}
+140.8
private String mPrimaryCorrelationKey;
public String getPrimaryCorrelationKey()
{
long current = System.currentTimeMillis();
current++;
return new Long(current).toString();
}
public void setPrimaryCorrelationKey(String mPrimaryCorrelationKey) {
this.mPrimaryCorrelationKey = mPrimaryCorrelationKey;
}
соответствующий геттер для этой проперти должен возвращать всегда уникальный id
+143
public final class SqliteWrapper {
private static final String SQLITE_EXCEPTION_DETAIL_MESSAGE
= "unable to open database file";
...
// FIXME: need to optimize this method.
private static boolean isLowMemory(SQLiteException e) {
return e.getMessage().equals(SQLITE_EXCEPTION_DETAIL_MESSAGE);
}
...
}
Android source
+145
Field maxx, minx, maxy, miny = row.getFields().toArray(new Field[0])[0];
minx = maxx = maxy = miny;
Адская комбинация.
+64.6
private static final int LENGHT255 = 255;
private static final int LENGHT450 = 450;
private static final int LENGHT3 = 3;
private static final int LENGHT5 = 5;
Константы для проставления длин в Entity.
+139
это твой щенок. теперь он твой навсегда.
и ты не хочешь, но считаешь его дни и года.
твоя любовь к нему огромна, с каждым днём она растёт.
она станет бесконечной,
когда он умрёт.
для виолет_салмон
+81.3
private final String zeroValueString="0";
private final String sevenValueString="7";
Если б можно, то ещё б и hundredElevenValueString = "111"; впиндюрили бы
+133.4
// parse from the uninstall, the actuall installation path
try {
int jarLoc = uninstallDir.indexOf("-jar");
String s = uninstallDir.substring(jarLoc + 5);
// turn it into a normalized file
int uniLoc = s.indexOf("uninstaller");
s = s.substring(1,uniLoc);
s = s.replace("\\", "/");
if(s.endsWith("/"))
s = s.substring(0,s.length()-1);
File f = new File(s);
if(!f.exists()) {
throw new Exception("installation directory does not exist: " + s);
}
return f;
}
catch(Exception e) {
throw new Exception("installation directory could not be parsed from: " + uninstallDir);
}
Typical code of one highly paid "tech expert" from USA
Exception handling makes me cry, this guy doesn't even now about any other exception classes
+89.9
static char DigitToChar(
int _Digit
)
{
switch (_Digit)
{
case 0: return '0';
case 1: return '1';
case 2: return '2';
case 3: return '3';
case 4: return '4';
case 5: return '5';
case 6: return '6';
case 7: return '7';
case 8: return '8';
case 9: return '9';
default: return ':';
}
}
в результате долгих размышлений всетаки заменили на return '0' + _Digit;