Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
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]
  ignore  |  Print  
  What's with unorganized code?  (Read 3067 times)
0 Members and 1 Guest are viewing this topic.
Offline ctomni231

JGO Wizard


Medals: 99
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Reply #30 - Posted 2014-06-24 04:44:59 »

Whoa, seems someone got caught in some kind of bear trap...  Pointing

Java, Java, Java... structs are way overdo. Why do you allow people to write code like the OP when you can have us write it in 5 lines... maybe less?

1  
2  
3  
4  
5  
struct Troint{
       public int n;
       public int p;
       public int v;
}


Come on Java, stop holding out on us.  Clueless

Offline Roquen
« Reply #31 - Posted 2014-06-24 05:17:58 »

Ah! Ah!  All of you: stop!   You're making my eyes bleed.
Offline micecd

Senior Newbie





« Reply #32 - Posted 2014-06-24 08:30:54 »

Woah Woah what is that 0.o
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Gibbo3771
« Reply #33 - Posted 2014-06-24 10:24:57 »

Even code I write myself I use private and non specific access fields, why? I come back to the code weeks later and I can't access that field, it was probably for a reason. Some things just should not be changed, even if you know you will forget.

Also I will just come right out and tell you to get the giant stick out your ass, your code is no different from what mine was the day I started coding.

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Offline Abuse

JGO Knight


Medals: 12


falling into the abyss of reality


« Reply #34 - Posted 2014-06-24 10:28:26 »

Disorganised...

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline hwinwuzhere
« Reply #35 - Posted 2014-06-24 12:20:25 »

Even code I write myself I use private and non specific access fields, why? I come back to the code weeks later and I can't access that field, it was probably for a reason. Some things just should not be changed, even if you know you will forget.

I fully agree. Some fields and methods are designed to be private for a specific class.

What did the boolean say to the integer? You can't handle the truth.
Offline KevinWorkman

JGO Wizard


Medals: 70
Projects: 11
Exp: 12 years


klaatu barada nikto


« Reply #36 - Posted 2014-06-24 13:21:14 »

How would I improve the readability any more than this?

I listed several things wrong with your code above. I'd start by fixing those.

More generally, your whole attitude tells more about you as a programmer than your code does. I get that this was a light-hearted boasting of some code you're proud of, and that's cool, but good programmers know that there is always more to learn.

You could have started this thread with a "hey guys, I think this code is particularly well-done, can anybody give me pointers on how to improve it further?", but instead you immediately started by calling your code "godly". Some of the best Java game developers in the world frequent these forums. Do you really think your code is better than theirs? If not, what's the point of the approach you took?

If I was looking to hire somebody for a coding position, and this thread was your resume, you wouldn't get the job.

The code you posted and the way that you posted it say a lot about you: you're probably still in high school. You probably have never worked on a real team (outside of perhaps homework assignments). You probably haven't finished any non-trivial projects. You probably get decent grades, but you haven't taken any advanced classes yet. You might have one big project that you daydream about finishing, but really you think and talk about it more than you code it. You seem a bit full of yourself and you don't seem to respond to criticism well, which is something that you'll have to get over if you want to be a real programmer.

(Not that there's anything wrong with any of the above, but if you make a thread calling your code "godly", you're inviting criticism.)

How far off am I? :p

Static Void Games - Play indie games, learn game programming, upload your own games!
Offline RobinB

JGO Ninja


Medals: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #37 - Posted 2014-06-24 14:15:26 »

How would I improve the readability any more than this?

I listed several things wrong with your code above. I'd start by fixing those.

More generally, your whole attitude tells more about you as a programmer than your code does. I get that this was a light-hearted boasting of some code you're proud of, and that's cool, but good programmers know that there is always more to learn.

You could have started this thread with a "hey guys, I think this code is particularly well-done, can anybody give me pointers on how to improve it further?", but instead you immediately started by calling your code "godly". Some of the best Java game developers in the world frequent these forums. Do you really think your code is better than theirs? If not, what's the point of the approach you took?

Best way to get input on the internet is to claim you're better then others, if he was asking advise, he would not even have gotten half the comments he has now Smiley
But i totally agree on you.
Offline KevinWorkman

JGO Wizard


Medals: 70
Projects: 11
Exp: 12 years


klaatu barada nikto


« Reply #38 - Posted 2014-06-24 14:26:02 »

Best way to get input on the internet is to claim you're better then others, if he was asking advise, he would not even have gotten half the comments he has now Smiley
But i totally agree on you.

Haha! Sounds like Cunningham's Law: "The best way to get the right answer on the Internet is not to ask a question, it's to post the wrong answer."

Static Void Games - Play indie games, learn game programming, upload your own games!
Offline micecd

Senior Newbie





« Reply #39 - Posted 2014-06-24 17:07:05 »

How would I improve the readability any more than this?

More generally, your whole attitude tells more about you as a programmer than your code does. I get that this was a light-hearted boasting of some code you're proud of, and that's cool, but good programmers know that there is always more to learn.

The code you posted and the way that you posted it say a lot about you: you're probably still in high school. You probably have never worked on a real team (outside of perhaps homework assignments). You probably haven't finished any non-trivial projects. You probably get decent grades, but you haven't taken any advanced classes yet. You might have one big project that you daydream about finishing, but really you think and talk about it more than you code it. You seem a bit full of yourself and you don't seem to respond to criticism well, which is something that you'll have to get over if you want to be a real programmer.


How far off am I? :p

I am past highschool. I don't think I don't respond to criticism well, but it's funny to see that others think I seem like I'm still in highschool though Tongue

Just wanted a response.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gene9

Senior Member


Medals: 10



« Reply #40 - Posted 2014-06-25 16:50:35 »

And you may be asking yourself, wtf is a TROINT? It's just a Point with 3 coordinates instead of 2 like a normal point. Dealing with Hexagons that is....

Don't make up your own wacky name. It's a Vec3i. Or a Point3i.

You probably should use one of the zillions of existing classes rather than rolling your own, unless you're doing your own engine.

This code highlights Java's flaws in making something so simple, so verbose and filled with lots of details that distract from it's function. Look at the Scala version:

1  
case class Vec3i(val a1: Int, val a2: Int, val a3: Int)


Or the Haskell version:

1  
data Vec3i = Vec3i Int Int Int deriving (Show)


Such a simple type should really be a one-liner.
Offline gene9

Senior Member


Medals: 10



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

Java, Java, Java... structs are way overdo. Why do you allow people to write code like the OP when you can have us write it in 5 lines... maybe less?

1  
2  
3  
4  
5  
struct Troint{
       public int n;
       public int p;
       public int v;
}


Come on Java, stop holding out on us.  Clueless

- The Scala and Haskell versions in my previous post are way more concise. One line rather than a bulky 5.
- Even in Java, I would write that much more concise. Use immutable final fields and don't bother with getter functions.

1  
2  
3  
4  
5  
    public class Vec3i {
        public final int a1, a2, a3;

        public Vec3i(int a1, int a2, int a3) { this.a1 = a1; this.a2 = a2; this.a3 = a3; }
    }


- The C# version has the disadvantage of being mutable and having really obscure rules around that. C# architect says that this was a mistake in the language: http://blogs.msdn.com/b/ericlippert/archive/2008/05/14/mutating-readonly-structs.aspx
- C# has internal efficiency advantages with structs over Java, Scala, and Haskell.
- Java 9 will have proper value types in Java, that are fully immutable and runtime efficient. I'm sure Scala will take advantage of this.
- Haskell has newtype and Scala has it's single field value types, but those are limited to single fields. JDK 9 will be better.


Offline Roquen
« Reply #42 - Posted 2014-06-26 05:15:07 »

Immutable is overrated for hard/soft realtime and system programming.  In many languages you don't even need to define a type for this.
Offline gene9

Senior Member


Medals: 10



« Reply #43 - Posted 2014-06-26 15:49:51 »

Immutable is overrated for hard/soft realtime and system programming.  In many languages you don't even need to define a type for this.

Overrated? There are several advantages and zero drawbacks.

Many languages will let you use a tuple... A simple type is appropriate in a statically typed language. And ideally, it's a single line like Scala/Haskell/others.
Offline Roquen
« Reply #44 - Posted 2014-06-26 18:45:02 »

Zero drawback?  How it's required to be lowered = large drawback.  And yes, a tuple shouldn't require any type definition.
Offline gene9

Senior Member


Medals: 10



« Reply #45 - Posted 2014-06-26 22:38:56 »

Zero drawback?  How it's required to be lowered = large drawback.  And yes, a tuple shouldn't require any type definition.

I don't comprehend "How it's required to be lowered = large drawback"

On second thought, a tuple with an optional type alias is a better choice than a distinct type.

Scala

1  
2  
3  
4  
5  
6  
// Alias to tuple
type Vec3i = (Int, Int, Int)
// Function
def addVec3i(v1: Vec3i, v2: Vec3i) = (v1._1 + v2._1, v1._2 + v2._2, v1._3 + v2._3)
// Example usage
addVec3i((1,2,3),(5,5,5))


Haskell

1  
2  
3  
4  
5  
6  
7  
-- Alias to tuple
type Vec3i = (Int, Int, Int)
-- Function
addVec3i :: Vec3i -> Vec3i -> Vec3i
addVec3i (x1, y1, z1) (x2, y2, z2) = (x1 + x2, y1 + y2, z1 + z2)
-- Example usage
addVec3i (1,2,3) (5,5,5)

Offline Roquen
« Reply #46 - Posted 2014-06-27 05:34:51 »

It means you're not thinking low-level and what must happen with immutable types.
Offline matheus23

JGO Kernel


Medals: 107
Projects: 3


You think about my Avatar right now!


« Reply #47 - Posted 2014-06-27 15:54:39 »

Immutable is overrated for hard/soft realtime and system programming.

I'm gonna hop in as a haskell fanboy (for / right now).

I'm not going to say that Immutability is THE thing, but in the general case it has proven itself to be working good enough and with a lot of advantages in functional languages.

The nice thing about haskell is also not that it's only got immutable data, because it hasn't. Things that work better with mutability can use gems like ArrayST, which is still type-safe because of nice abstractions.

(Clearly I think that haskell's strong and almost-pure type system is the nice thing about it. Monads ruuule ;P )

See my:
    My development Blog:     | Or look at my RPG | Or simply my coding
http://matheusdev.tumblr.comRuins of Revenge  |      On Github
Offline Roquen
« Reply #48 - Posted 2014-06-27 16:17:08 »

No comment on Haskell.   It just isn't suited for system programming.  That whole hammer/nail meme thing.
Offline gene9

Senior Member


Medals: 10



« Reply #49 - Posted 2014-06-28 20:58:27 »

No comment on Haskell.   It just isn't suited for system programming.  That whole hammer/nail meme thing.

No comment on Haskell? Followed by a comment on Haskell?

Java + Scala probably aren't suited for real systems programming either. All three are more for applications programming + server programming.

There are definitely advantages to mutability for certain data structures, and while I love Haskell and its extreme immutability, I'm not arguing that that is always the best tool. But for a three integer tuple, I see a completely pareto improvement for immutability with zero drawback.
Offline kinaite

Junior Member


Projects: 2



« Reply #50 - Posted 2014-06-28 22:50:27 »

I'm the only one here that organize the code like this:
1  
2  
3  
4  
public void method()
{
  //stuff
}


and not like this:
1  
2  
3  
public void method(){
 //stuff
}
Offline Drenius
« Reply #51 - Posted 2014-06-28 22:51:12 »

Nope.
Offline Roquen
« Reply #52 - Posted 2014-06-29 13:13:31 »

[No comment on Haskell? Followed by a comment on Haskell?
Are you being serious or just purposely obtuse?

Quote
Java + Scala probably aren't suited for real systems programming either. All three are more for applications programming + server programming.
No argument.  The JVM doesn't give the needed tools.
Pages: 1 [2]
  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.

BurntPizza (22 views)
2014-09-19 03:14:18

Dwinin (35 views)
2014-09-12 09:08:26

Norakomi (62 views)
2014-09-10 13:57:51

TehJavaDev (88 views)
2014-09-10 06:39:09

Tekkerue (44 views)
2014-09-09 02:24:56

mitcheeb (65 views)
2014-09-08 06:06:29

BurntPizza (47 views)
2014-09-07 01:13:42

Longarmx (35 views)
2014-09-07 01:12:14

Longarmx (40 views)
2014-09-07 01:11:22

Longarmx (36 views)
2014-09-07 01:10:19
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

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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!