Post the worst code styles you have found.
I’ll start:
public class MYCLASS-1{
//Spacing intended
private static void _UPDATEDISPLAYRESOLUTIONWITHNEW(_WIDTH, _HEIGHT){
}
}
Post the worst code styles you have found.
I’ll start:
public class MYCLASS-1{
//Spacing intended
private static void _UPDATEDISPLAYRESOLUTIONWITHNEW(_WIDTH, _HEIGHT){
}
}
public class Something {
public Something(int _something, double __somethingelse__) {
}
//private void everything() {
//
//}
//
//
//
/**
private void commentedMethodAndStuff() {
}
**/
}
Seriously, I hate comments in code. My classmates use them all the time
public class MyClass {
int variable;
String variable2;
MyClass(int v, String v2)
{
variable = v; variable2 = v2; }
void method1(){
System.out.println(variable);
}
// etc.. etc...
}
People don’t know how to fucking format their code…
Buitiful
public class badCode extends HorribleCode {
public badCode() {
System.out.println("Neat isn't it?");
}
}
This kills me inside errytime
public void stuff()
{
}
Still not as bad as
public void stuff2()
{
{
}
}
Yes, I have actually seen this.
Digging through some really old projects, found a completely pointless [icode]if(true)[/icode] in the wild:
case MODE_FULLSCREEN:
if(true) {
if(vc.isDisplayChangeSupported()) {
DisplayMode[] ds = vc.getDisplayModes();
if(resflag == HIGHEST_RESOLUTION) {
for(int i=0;i<ds.length;i++) {
if(ds[i].getWidth() > resolution.width) {
resolution.width = ds[i].getWidth();
vc.setDisplayMode(ds[i]);
}
if(ds[i].getHeight() > resolution.height) {
resolution.height = ds[i].getHeight();
vc.setDisplayMode(ds[i]);
}
}
} else if(resflag == LOW_RESOLUTION) {
throw new UnsupportedOperationException("Not supported yet.");
} else { //use existing resolution
resolution = new Dimension(originalMode.getWidth(),originalMode.getHeight());
}
}
w = resolution.width;
h = resolution.height;
windowSize = new Dimension(w,h);
window.setSize(w, h);
window.setUndecorated(true);
vc.setFullScreenWindow(window);
if(buffermode == BUFFER_MODE_STRATEGY) {
window.createBufferStrategy(NUM_BUFFERS);
} else {
buffer = vc.getDefaultConfiguration().createCompatibleVolatileImage(vc.getDisplayMode().getWidth(),vc.getDisplayMode().getHeight());
window.setVisible(false);
}
break;
}
That’s all in one [icode]case:[/icode] branch. Bleehh. Also the UnsupportedOperationException. Bleeeh.
How about the endless classes filled with:
@override
public void overridingMethodThingy() {
// Override to do nothing (really... NOTHING!)
}
You need this ‘useless’ piece of code sometimes.
Yes I agree, but sometimes you have classes filled with these (and with ‘filled’ I mean 10-20 methods of uselessness) and those classes don’t do anything.
Obscure peephole optimisations:
- throw new NullPointerException();
+ throw null;
Yes I agree, but sometimes you have classes filled with these (and with ‘filled’ I mean 10-20 methods of uselessness) and those classes don’t do anything.
They’re use to override a method, and not run the code in the parent class.
while(true)
continue;
Obscure peephole optimisations:
- throw new NullPointerException(); + throw null;
Alright, I laughed.
Still not as bad as
public void stuff2() { { } }
Yes, I have actually seen this.
BTW, why is that not a compiler error ? why can you just open a block and close it ? with no keyword before it it makes no sense, why would this be allowed syntax
so you can create local scopes
its like being able to have a semicolon by itself amirite
Riven:Obscure peephole optimisations:
- throw new NullPointerException(); + throw null;
Alright, I laughed.
Holy shit. THIS CHANGES EVERYTHING!
BTW, why is that not a compiler error ? why can you just open a block and close it ? with no keyword before it it makes no sense, why would this be allowed syntax
I guess for an organization strategy.
public void stuff(){
{
int width, height;
}
Display.setResolution(width, height);
}
@Cero: If the compiler had to take into account whether code made sense, we wouldn’t have enterprise applications. (Thank you, I’ll be here all week) A compiler merely checks whether code is legal as per the language spec. You can define arbitrary scopes to limit the… scope of local variables.
Cero:BTW, why is that not a compiler error ? why can you just open a block and close it ? with no keyword before it it makes no sense, why would this be allowed syntax
I guess for an organization strategy.
public void stuff(){ { int width, height; } Display.setResolution(width, height); }
LOL this wouldn’t even compile width and height would be out of scope in the setResolution command.
also
public class Tuna{
int apples;
int tomato;
}
public class Bucky{
}
public class NoMeaninfulClassNamesOrFnNames{
}