Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (511)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (577)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2 3
  ignore  |  Print  
  Code-style: Cringe pics  (Read 3024 times)
0 Members and 1 Guest are viewing this topic.
Offline Spacebeans
« Posted 2014-06-03 19:58:45 »

Post the worst code styles you have found.

I'll start:

1  
2  
3  
4  
5  
6  
public class MYCLASS-1{
 //Spacing intended
 private static void _UPDATEDISPLAYRESOLUTIONWITHNEW(_WIDTH, _HEIGHT){

 }
}
Offline hwinwuzhere
« Reply #1 - Posted 2014-06-03 20:02:41 »

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
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 Sad

There are two kinds of people in this world: Those who can extrapolate from incomplete data,
Offline ra4king

JGO Kernel


Medals: 350
Projects: 3
Exp: 5 years


I'm the King!


« Reply #2 - Posted 2014-06-03 20:05:25 »

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
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...

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline AppleSauce
« Reply #3 - Posted 2014-06-03 20:06:21 »


Buitiful

1  
2  
3  
4  
5  
6  
7  
8  
   public class badCode extends HorribleCode {
     
public badCode() {
                          System.out.println("Neat isn't it?");
   
                                   }
     
                                   }
Offline NegativeZero

JGO Knight


Medals: 30
Projects: 2
Exp: 3 years


Zero but not.


« Reply #4 - Posted 2014-06-03 20:11:16 »

This kills me inside errytime
1  
2  
3  
4  
public void stuff()
{

}
Offline Spacebeans
« Reply #5 - Posted 2014-06-03 20:16:46 »

1  
2  
3  
4  
public void stuff()
{

}


Still not as bad as

1  
2  
3  
4  
5  
6  
7  
public void stuff2()

 {
    {

    }
 }


Yes, I have actually seen this.
Offline BurntPizza
« Reply #6 - Posted 2014-06-03 20:17:20 »

Digging through some really old projects, found a completely pointless
if(true)
in the wild:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
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
case:
branch. Bleehh. Also the UnsupportedOperationException. Bleeeh.
Offline hwinwuzhere
« Reply #7 - Posted 2014-06-03 20:17:23 »

How about the endless classes filled with:

1  
2  
3  
4  
@override
public void overridingMethodThingy() {
 // Override to do nothing (really... NOTHING!)
}

There are two kinds of people in this world: Those who can extrapolate from incomplete data,
Offline trollwarrior1
« Reply #8 - Posted 2014-06-03 20:18:35 »

How about the endless classes filled with:

1  
2  
3  
4  
@override
public void overridingMethodThingy() {
 // Override to do nothing (really... NOTHING!)
}


You need this 'useless' piece of code sometimes.
Offline hwinwuzhere
« Reply #9 - Posted 2014-06-03 20:20:25 »

How about the endless classes filled with:

1  
2  
3  
4  
@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.

There are two kinds of people in this world: Those who can extrapolate from incomplete data,
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #10 - Posted 2014-06-03 20:21:23 »

Obscure peephole optimisations:
1  
2  
-    throw new NullPointerException();
+    throw null;

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline Spacebeans
« Reply #11 - Posted 2014-06-03 20:22:01 »

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.
Offline Drenius
« Reply #12 - Posted 2014-06-03 20:22:09 »

1  
2  
while(true)
    continue;
Offline BurntPizza
« Reply #13 - Posted 2014-06-03 20:22:41 »

Obscure peephole optimisations:
1  
2  
-    throw new NullPointerException();
+    throw null;


Alright, I laughed.
Offline Cero
« Reply #14 - Posted 2014-06-03 20:37:02 »

Still not as bad as

1  
2  
3  
4  
5  
6  
7  
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 :/

Offline Agro
« Reply #15 - Posted 2014-06-03 20:42:51 »

so you can create local scopes Tongue
its like being able to have a semicolon by itself amirite

Offline theagentd
« Reply #16 - Posted 2014-06-03 20:44:24 »

Obscure peephole optimisations:
1  
2  
-    throw new NullPointerException();
+    throw null;


Alright, I laughed.
Holy shit. THIS CHANGES EVERYTHING!

Myomyomyo.
Offline Spacebeans
« Reply #17 - Posted 2014-06-03 20:44:53 »

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.

1  
2  
3  
4  
5  
6  
7  
public void stuff(){
    {
      int width, height;
    }

    Display.setResolution(width, height);
}
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 816
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #18 - Posted 2014-06-03 20:45:44 »

@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.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings
Offline The Lion King
« Reply #19 - Posted 2014-06-03 21:52:19 »

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.

1  
2  
3  
4  
5  
6  
7  
public void stuff(){
    {
      int width, height;
    }

    Display.setResolution(width, height);
}


LOL this wouldn't even compile Smiley width and height would be out of scope in the setResolution command.

also
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
public class Tuna{
     int apples;
     int tomato;
}

public class Bucky{

}

public class NoMeaninfulClassNamesOrFnNames{

}


"You have to want it more than you want to breath, then you will be successful"
Offline HeroesGraveDev

JGO Kernel


Medals: 269
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #20 - Posted 2014-06-04 01:53:07 »


1  
2  
3  
4  
5  
6  
7  
public void stuff2()

 {
    {

    }
 }



Those are called quickscopes. Grin

Offline kpars

JGO Wizard


Medals: 96
Projects: 4
Exp: 3 years


Extreme Typist.


« Reply #21 - Posted 2014-06-04 02:06:41 »

If this thread is supposed to be satirical, here you go:

1  
2  
3  
4  
5  
6  
7  
8  
9  
public class Jeviny extends JGOMember{
public Jeviny (){
  super(0);}
Texture jev;
public void init(ResourceManager r){jev=TextureLoader.loadTexture("/jev.jif");};
public void update(float d){System.out.println(new Random().nextInt(1337));shit_post();}
public void render(Graphics g){ g.drawTexture(jev);
 }public static void main(String[] a){new Jeviny();} // d
}

If this thread is supposed to demonstrate actual cringy coding styles/formatting, there's a video you should watch.

- Jev

Offline Spacebeans
« Reply #22 - Posted 2014-06-04 17:45:53 »


I guess for an organization strategy.

1  
2  
3  
4  
5  
6  
7  
public void stuff(){
    {
      int width, height;
    }

    Display.setResolution(width, height);
}

LOL this wouldn't even compile Smiley width and height would be out of scope in the setResolution command.

Yeah, I noticed that once I posted it. My bad!

Also, are you Bucky? My friend told be thenewboston writes the same way.
Offline opiop65

JGO Kernel


Medals: 156
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #23 - Posted 2014-06-04 17:51:11 »

No, he's impersonating Bucky and making fun of him for using weird, un-descriptive class names.

Offline trollwarrior1
« Reply #24 - Posted 2014-06-04 18:09:58 »

I came across this piece of incredibly awesome looking code:

Its in some kind of c++ type language, but still fits the topic, so...
1  
2  
MyClass* myClass = new MyClass();
if(myClass) myClass.doSomething();
Offline trollwarrior1
« Reply #25 - Posted 2014-06-04 18:13:51 »

Another thing that makes me cringe is..

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
public void doSomething()
 {
  new Thread()
   {
    public void run()
    {
     System.out.println("This code..");
    }
   }.start();
 }



I also really hate this..
1  
2  
int integer=10; // bad
int integer = 10; // good
Offline BurntPizza
« Reply #26 - Posted 2014-06-04 18:20:43 »

I also really hate this..
1  
2  
int integer=10; // bad
int integer = 10; // good


Even worse is inconsistency:
int x= 10;
  Yawn

Offline trollwarrior1
« Reply #27 - Posted 2014-06-04 18:39:05 »

Ow god that is even worse than my examples... Wow.. It just looks soooo bad...
Offline Drenius
« Reply #28 - Posted 2014-06-04 18:41:17 »

It does, but it does not make it harder to read so...
Offline opiop65

JGO Kernel


Medals: 156
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #29 - Posted 2014-06-04 18:42:06 »

But its disgusting to look at. One should take pride in their code, especially how it looks...

Pages: [1] 2 3
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (52 views)
2014-10-17 03:59:02

Norakomi (42 views)
2014-10-16 15:22:06

Norakomi (32 views)
2014-10-16 15:20:20

lcass (37 views)
2014-10-15 16:18:58

TehJavaDev (68 views)
2014-10-14 00:39:48

TehJavaDev (66 views)
2014-10-14 00:35:47

TehJavaDev (58 views)
2014-10-14 00:32:37

BurntPizza (73 views)
2014-10-11 23:24:42

BurntPizza (45 views)
2014-10-11 23:10:45

BurntPizza (85 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!