Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (600)
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 3187 times)
0 Members and 1 Guest are viewing this topic.
Offline Rayvolution

« JGO Spiffy Duke »


Medals: 246
Projects: 2
Exp: 1 year


Resident Crazyman


« Reply #60 - Posted 2014-06-05 19:32:20 »

I don't see the need for the on/off setters, unless reflection is used to tie functionality to UI. Having said that, eww!

*looks around shifty eyed*

Kinda hard to explain my GUI code, but I "kind of" do that in some areas. My GUI code itself doesn't actually control anything in the engine, but sometimes the GUI needs to know if the game is in a certain state so it knows what to do with a button.

for example, these lines do not actually turn on and off accentMode, it just toggles highlighting/unhighlighting the button. But I plan to refactor it to just ask the game if highlight mode is on. For whatever reason it's still using it's own internal boolean. (and that's completely retarded) Just a throwback from when my GUI wasn't in it's own class files like it should be. :/
1  
2  
3  
   public void lockAccentMode(){accentModeLock = !accentModeLock;}
   public void accentModeOn(){accentMode = true;}
   public void accentModeOff(){accentMode = false;}


My new GUI system though, should eliminate this anyway. I just haven't made it over to this area of code to refactor it into the "new" GUI code layout.

- Raymond "Rayvolution" Doerr.
Retro-Pixel Castles - Survival Sim/Builder/Roguelike!
LIVE-STREAMING DEVELOPMENT: http://www.twitch.tv/SG_Rayvolution
Offline Screem
« Reply #61 - Posted 2014-06-05 20:00:57 »

I can't resist the urge to edit your code, Rayvolution:
1  
public void setAccentMode(boolean on) { accentMode = on; }


I found this:
1  
2  
3  
4  
5  
int length= 0;
for(int i = 0; i < array.length; i++){
    length++;
}
System.out.println("Array has " + length + " elements.");


Going through some old code, I found this:
1  
2  
3  
4  
5  
6  
7  
8  
if(someCondition) {
   if(anotherCondition) {
      if(yetAnotherCondition) {
         SomeObject object = aParameter;
         if(ANOTHERcondition) {
            if(lastCondition) {
               AnotherObject object2 = getOtherObject();
               if(object2 != null) {

I removed the conditions and changed object names to remove confusion, my code wasn't THAT terrible. But six nested if statements, anyone?
Offline Rayvolution

« JGO Spiffy Duke »


Medals: 246
Projects: 2
Exp: 1 year


Resident Crazyman


« Reply #62 - Posted 2014-06-05 20:03:38 »

I can't resist the urge to edit your code, Rayvolution:
1  
public void setAccentMode(boolean on) { accentMode = on; }


1  
public void setAccentMode(boolean state) { accentMode = state; }

..since the state isnt always "on" Cheesy

- Raymond "Rayvolution" Doerr.
Retro-Pixel Castles - Survival Sim/Builder/Roguelike!
LIVE-STREAMING DEVELOPMENT: http://www.twitch.tv/SG_Rayvolution
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ags1

JGO Wizard


Medals: 75
Projects: 3
Exp: 5 years


Make code not war!


« Reply #63 - Posted 2014-06-05 20:08:43 »

"On" can be true or false... But "state" must always be true!

Offline kpars

JGO Kernel


Medals: 119
Projects: 5
Exp: 4 years


Radirius Games


« Reply #64 - Posted 2014-06-05 20:31:40 »

I found this:

-snip-

You win.

- Jev

Offline Rayvolution

« JGO Spiffy Duke »


Medals: 246
Projects: 2
Exp: 1 year


Resident Crazyman


« Reply #65 - Posted 2014-06-05 20:32:40 »

"On" can be true or false... But "state" must always be true!

eh? wouldn't "on" be true and "state" be "the state you want to set it to"?

- Raymond "Rayvolution" Doerr.
Retro-Pixel Castles - Survival Sim/Builder/Roguelike!
LIVE-STREAMING DEVELOPMENT: http://www.twitch.tv/SG_Rayvolution
Offline ags1

JGO Wizard


Medals: 75
Projects: 3
Exp: 5 years


Make code not war!


« Reply #66 - Posted 2014-06-05 20:38:03 »

If you have red and green apples, you could have boolean red equal to true or false. But if you had a boolean "color" it would always be true  Smiley

Online BurntPizza

« JGO Bitwise Duke »


Medals: 286
Exp: 5 years



« Reply #67 - Posted 2014-06-05 20:39:17 »

Well now you're comparing apples and rhinoceroses.
Offline matheus23

JGO Kernel


Medals: 114
Projects: 3


You think about my Avatar right now!


« Reply #68 - Posted 2014-06-05 20:48:19 »

If you have red and green apples, you could have boolean red equal to true or false. But if you had a boolean "color" it would always be true  Smiley

Well now you're comparing apples and rhinoceroses.

Nah, she's right (she, right?).
But I'd offer the compromise:
boolean isOn
.

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline JVallius
« Reply #69 - Posted 2014-06-05 20:51:42 »

Once I wrote duplicate code.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #70 - Posted 2014-06-05 20:59:18 »

Actually, one thing I do that I know makes some people cringe is how I "compress" my getters and setters at the end of my class files into one line. But I've always liked it this way;

1  
2  
   public int getTileId(int tileX, int tileY, int layer){return mapArray[tileX][tileY][layer];}
   public String getTileProperty(int tileID, String property, String def){return mtl.getTileProperty(tileID, property, def);}


I always do this!
Thought i was the only one Cheesy
Online BurntPizza

« JGO Bitwise Duke »


Medals: 286
Exp: 5 years



« Reply #71 - Posted 2014-06-05 21:04:12 »

Now that I think of it:

Actually, one thing I do that I know makes some people cringe is how I "compress" my getters and setters at the end of my class files into one line.

That's what code folds are for!
Offline kpars

JGO Kernel


Medals: 119
Projects: 5
Exp: 4 years


Radirius Games


« Reply #72 - Posted 2014-06-05 21:13:12 »

I always have hated it when people name their bools things like
isRunning
. I have no idea why.

I also have a bad habit of
naming_my_functions_like_this()
.

- Jev

Online BurntPizza

« JGO Bitwise Duke »


Medals: 286
Exp: 5 years



« Reply #73 - Posted 2014-06-05 21:17:00 »

Ugh C function convention.

In Clojure (lisps in general I believe) the convention is hyphens (although I guess that's only if you couldn't figure out a good 1 word name):
(rand-int nitems)
which I'm not sure what to make of. It does kinda fit, (much better than camelCase in a lisp anyway) but still seems alien. I guess all styles can-be-abused.
Offline JESTERRRRRR

Senior Devvie


Medals: 7
Exp: 1 year



« Reply #74 - Posted 2014-06-06 19:15:31 »

Inside some long complicated pathfinding method

Vector3f temp1 = ...
Vector3f temp2 = ...
Vector3f t3 = temp1.distance(temp2);
Vector3f m1 = temp1.distance(t2);

and so on with the variable names
Offline saucymeatman
« Reply #75 - Posted 2014-06-06 19:38:56 »

I dont like code that is inherently awkward to read.
A great example of this is the isState boolean expression.

For example, consider :
1  
2  
if (!isRunning())
start();


Read in my mind as :
"if not is running then start"

But if we name the boolean expression 'state' in place of 'isState' then it can be unclear at first glance what the expression represents with certain state names.
Pages: 1 2 [3]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

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

The first screenshot will be displayed as a thumbnail.

rwatson462 (28 views)
2014-12-15 09:26:44

Mr.CodeIt (19 views)
2014-12-14 19:50:38

BurntPizza (37 views)
2014-12-09 22:41:13

BurntPizza (72 views)
2014-12-08 04:46:31

JscottyBieshaar (34 views)
2014-12-05 12:39:02

SHC (46 views)
2014-12-03 16:27:13

CopyableCougar4 (42 views)
2014-11-29 21:32:03

toopeicgaming1999 (110 views)
2014-11-26 15:22:04

toopeicgaming1999 (96 views)
2014-11-26 15:20:36

toopeicgaming1999 (29 views)
2014-11-26 15:20:08
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!