- 1
- 2
- 3
- 4
- 5
if (eventInfo.getQuoteList().size() == 0) {
lineInfo.getEventList().add(eventInfo);
} else {
lineInfo.getEventList().add(eventInfo);
}
Нашли или выдавили из себя код, который нельзя назвать нормальным, на который без улыбки не взглянешь? Не торопитесь его удалять или рефакторить, — запостите его на говнокод.ру, посмеёмся вместе!
+77
if (eventInfo.getQuoteList().size() == 0) {
lineInfo.getEventList().add(eventInfo);
} else {
lineInfo.getEventList().add(eventInfo);
}
Тебе никуда не деться от добавления!
+77
Superclass s = new Subclass();
((Subclass)s).useSubclassMethod();
Чудеса полиморфизма.
+77
private String isMasterExecuted(Bundle bl) {
String taskName = (String) bl.get("activeTaskName").toString();
String isExecuted = "No";
if(taskName.equals("Manage")) {
isExecuted = "Yes";
}
return isExecuted;
}
код индийского коллеги. С булевым типом он не знаком.
+77
if (!employees.equals("") && employees != null) {
+77
public static void main(final String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException, UnsupportedLookAndFeelException {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
JFrame.setDefaultLookAndFeelDecorated(false);
JDialog.setDefaultLookAndFeelDecorated(false);
} finally {
new ImageMaps().start();
}
}
НАКОНЕЦ запускаю десктоп-приложение.
Не знаю как вам, а по мне - выглядит весьма странно.
+77
try {
order.setAddress(address.clone());
} catch (CloneNotSupportedException e) {
// We will not get here, because priorAddressDtoToAdd.address is of Address type.
// Moreover - none of the subclasses throws this exception
LOG.error("Address clone is not supported? Nonsense...", e);
}
Это было бы даже весело, если бы не повторялось вместе с коментами 3 раза в одном классе.
+77
public class SomeServlet extends HttpServlet {
//...
private static final int ERROR_NOT_FOUND = 404;
private static final int ERROR_INTERNAL = 503;
//...
protected void doPost(HttpServletRequest req, HttpSerletResponse resp) {
//...
if (buff != null) {
if (buff.length == 0) {
resp.sendError(ERROR_INTERNAL);
}
//...
} else {
resp.sendError(ERROR_NOT_FOUND);
}
}
}
Велосипедисты взялись за сервлеты.
+77
public abstract class Data {
// The tone of Commander Riker's voice makes me suspect that
// he is not serious about finding Ambassador T'Pel charming.
// My experience suggests that in fact he may mean the exact
// opposite of what he says. Irony is a form of expression
// I have not yet been able to master.
+77
@SuppressWarnings("unchecked")
public void addImage(String key, Bitmap bmp){
if(memCache.size() >= MAX_CACHE_SIZE){
Object[] array = (Entry[]) cacheUsage.entrySet().toArray();
Arrays.sort(array, new Comparator<Object>(){
public int compare(Object object1, Object object2) {
return (Integer)(((Map.Entry<String, Integer>)object1).getValue()) -
(Integer)(((Map.Entry<String, Integer>)object2).getValue());
}
});
String keyForRemove = ((Map.Entry<String, Integer>)array[0]).getKey();
memCache.remove(keyForRemove);
cacheUsage.remove(keyForRemove);
}
}
до чего довело желание всё оптимизацировать
+77
public static <T> T createInstance(String className, Object ... ctorParams)
{
Class<T> type;
try {
type = (Class <T>) Class.forName(className);
}
catch (ClassNotFoundException e) { throw new RuntimeException(e); }
Class <?> [] paramTypes = new Class [ctorParams.length];
for(int i = 0; i < ctorParams.length; i ++)
paramTypes[i] = (Class <?>) ctorParams[i].getClass();
Constructor<T> ctor;
try {
ctor = type.getConstructor(paramTypes);
}
catch (SecurityException e) { throw new RuntimeException(e); }
catch (NoSuchMethodException e){ throw new RuntimeException(e); }
T instance;
try {
instance = ctor.newInstance(ctorParams);
}
catch (IllegalArgumentException e) { throw new RuntimeException(e); }
catch (InstantiationException e) { throw new RuntimeException(e); }
catch (IllegalAccessException e) { throw new RuntimeException(e); }
catch (InvocationTargetException e) { throw new RuntimeException(e); }
return instance;
}
Тут само Java вынуждает говнокодить. О святая простота!