Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Fabian11307yAlso there:
int start=0;
int end=array.length;
for(int index=start;index<end;index++){
//lalala
}
"start" and "end" are used nowhere else. The array does not change during the loop (which was a bit difficult to analyse). -
Fabian11307yAlso just found this (it's like negative easter):
boolean foo=false; // even marked as useless assignment by Eclipse
for(bla;bla;bla){
foo=method(aaaaa);
if(foo){
stuff;
}
} -
Fabian11307yIt keeps going... So many useless assignments and other weirdness. After understanding how the method works my task is to rewrite it more efficiently anyway, so for now I'm refactoring and I bet it's half its length when I'm done.
-
Fabian11307yOh wow, it actually sounds much more like natural English after refactoring. So there was no reason to do it differently before. The lines don't even become that long. They still fit on my vertical screen.
-
Fabian11307yAlso this:
if(bool){
boolean bar=true;
//lots of code
} else {
boolean bar=false;
//the exact same code again
} -
You know that you can simply edit your previous comment as long as it didn't reach the length limit xor time limit, right?
-
We have similar cases in my company, one's called PropertyMap. It has an attribute Map<String, Property> and around 4 methods like this:
public void meth(params){
map.meth(params);
}
WHY EVEN REWRITE EVERYTHING, WHY NOT
class PropertyMap extends HashMap<String, Property>{
... copy constructors
}
SO MANY TIMES I HAVE TO ADD ONE METHOD TO THOSE KIND OF CLASSES BECAUSE IT ONLY EXISTS IN THE INTERFACE THIS CLASS IS A SHITTY COPY OF
Related Rants
public static Map<Integer, List<Integer>> stuff(arguments) {
HashMap<Integer, List<Integer>> map = new HashMap<>();
method(map, otherVariables);
return map;
}
public static void method(HashMap map, otherVariables) {
map.put(things);
}
So... You know how to return a map from a method. Then why do you create the map outside the method and make it an argument that does not get returned, making it confusing because the map gets created empty, given to a different method, then returned, making it look like you're returning an empty map...
...instead of just creating it inside the called method, returning it and assigning it to a map in the calling method? Even if you think that would create another map (it doesn't), the compiler is intelligent and can optimise that away.
undefined
confusing code
return
java