Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (489)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (555)
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  
  Favourite name for vectors?  (Read 6186 times)
0 Members and 1 Guest are viewing this topic.
Offline Harley Rana

Junior Member




Java games rock!


« Posted 2003-04-02 04:56:55 »

Hey guys, its a personal question, close to the heart of all game programmers.  How do you name vectors?

We got a list to choose from :  vec3,vect3,Vec3,Vect3,Vector3,Vector3f,float3,and many more.

What do you like?


Offline cfmdobbie

Senior Member


Medals: 1


Who, me?


« Reply #1 - Posted 2003-04-02 05:22:39 »

I'm going to call all mine "Jennifer".

Hellomynameis Charlie Dobbie.
Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #2 - Posted 2003-04-02 06:05:52 »

I like that the vectors (indeed any field) are named after their purpose (No! I am not going to discuss the purpose of "Jennifer").
None of my fields are ever called vec3 or likewise.
cameraPosition is so much more understandable than vec3.

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

Senior Member




for great justice!


« Reply #3 - Posted 2003-04-02 06:23:59 »

I like names that make up sentences that BA might have said, so I call them things like "jibba", "jabba", "crazy" and "foo". It makes for very readable code too. If you're howlin' mad.
Offline GergisKhan

Junior Member




"C8 H10 N4 O2"


« Reply #4 - Posted 2003-04-02 13:11:01 »

Breakfast - that was very painful.

I'm using some crazy form of weak Hungarian (I think it is) or something like that, so I'd choose something like v3fIdentifier, where Identifier is what this thing's purpose is.  I also abstain on what v3fJennifer might be for.  *evil grin*

gK

"Go.  Teach them not to mess with us."
          -- Cao Cao, Dynasty Warriors 3
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #5 - Posted 2003-04-02 13:18:56 »

Please! No Hungarian notation! Hungarian notation only makes code less readable instead of more! If you can't identify your variable types, you need to clean up your code so you can see your definitions. After all, Hungarian notation was developed at MICROSOFT of all places. That should be a good tipoff that it's not a solution for clean code.

Java Game Console Project
Last Journal Entry: 12/17/04
Offline GergisKhan

Junior Member




"C8 H10 N4 O2"


« Reply #6 - Posted 2003-04-02 13:40:18 »

I agree with the MS comment, though I disagree on the readability.  I *HAVE* been using this scheme for almost four years now, and it's just what is comfortable for me.  As was mentioned earlier, it is an opinion.

gK

"Go.  Teach them not to mess with us."
          -- Cao Cao, Dynasty Warriors 3
Offline Breakfast

Senior Member




for great justice!


« Reply #7 - Posted 2003-04-02 13:42:45 »

Hungarian notation was developed by MS? Why is it called Hungarian notation? Why not Microsoftian Notation? Were the people of hungary even consulted?
Offline GergisKhan

Junior Member




"C8 H10 N4 O2"


« Reply #8 - Posted 2003-04-02 13:43:49 »

The gentleman who created it was Hungarian, I believe....


... goes along with how you get things like Reverse Polish Notation (which I think is absolutely brilliant, btw).

gK

"Go.  Teach them not to mess with us."
          -- Cao Cao, Dynasty Warriors 3
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #9 - Posted 2003-04-02 13:57:22 »

Love RPN. You can do math, left to right without ever worrying about "decoding" operator priority.  My biggest beef with Hungarian notation is that it smacks of a hack on top of a hack. Since the guys at Microsoft could no longer find what their variable definitions were, they created a syntactical standard that put the definitions in the name. Unfortunately, the world got trained to use it, and now we have the joys of code like "hwndMyWindow" even in Java where it's pretty much unnecessary.  But you're right, a lot of people use it and are used to it. Which is too bad for them, because I'm always on a crusade to get people to produce nothing but the cleanest code. Wink

Java Game Console Project
Last Journal Entry: 12/17/04
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline rgeimer

Senior Newbie





« Reply #10 - Posted 2003-04-02 15:34:18 »

Don't have a favorite name for vectors, but I usually call my buffers "buffy".
Offline cfmdobbie

Senior Member


Medals: 1


Who, me?


« Reply #11 - Posted 2003-04-02 16:29:30 »

Okay, I was kidding, but I have the horrible feeling you're being serious... Grin

With me, a temporary values are easy - a ByteBuffer will usually be called "bb", a Sprite will probably be "s", "i" is used for iterating over arrays (move on to "j" and "k" if nesting), and "x" and "y" are for iterating over two-dimensional arrays that have some concept of coordinates etc etc.  Longer-lived references are similarly standardised, but are descriptive based on use/contents rather than type.

I suppose it really doesn't matter what scheme you use as long as you're consistent.  I've developed my system so that I can look over code I'd written many moons before and understand what it all means with very little effort.  This is helped by good API design and liberal documentation.


I think the original question was specifically about the naming of vector types.  They're described in so many different ways that I'm sure all of the mentioned forms are present in an API somewhere.  I would stay with Capitalisations for class names, and would try to avoid suffixing with "3" - it's not hard to write a class that will represent all the dimensions you throw at it, and remember what it's supposed to be.  As for the length of the name (vec/vect/vector), I think that's entirely personal choice.  For me, I'd go with "Vector" because I don't like things unnecessarily abbreviated.  Ur mileage may vry.

Hellomynameis Charlie Dobbie.
Offline Breakfast

Senior Member




for great justice!


« Reply #12 - Posted 2003-04-02 18:04:42 »

When Edsger Dijkstra died last year I read a comment somewhere that not only did he contribute a huge amount to computer science but he was also the only high profile computer scientist to have the classic loop variables i, j and k in order in his name.
Offline Harley Rana

Junior Member




Java games rock!


« Reply #13 - Posted 2003-04-03 00:59:40 »

Quote
horrible feeling you're being serious...

well, half serious, half tounge firmly in place. Cheesy

Hey cfmdobbie this is what happends when you ask a question, you find out more than you wanted to know. Smiley

Hungarian notation was created to solve scope problems in C, so theres not much need for it now.  Except hordes of people still love it.  Smiley  Seems to be really popular with C++ coders.  Its just what your used to and like i guess.

Im growing fonder of float3.  The same naming as the CG language.  You won't find any cleaner! Smiley
I know im breaking the sacred java rules, but i'll live.
Offline mill

Junior Member




popcorn freak


« Reply #14 - Posted 2003-04-03 04:47:53 »

since i'm a XP friend, i always use long informative names. not it's not hard or time consuming to write since either a) i'm fast or b) i press CTRL+SPACE in Eclipse Smiley

makes code so much easier to read. one thing that annoys me reading other's code is that people shorten already short variables like Proc for Process! (they do at the university in the OS course, silly)

anyway, i like the JCS since 'coding conventions' is one of the xp practices and it's easy to point people to sun's site and read it there.

Grin

Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #15 - Posted 2003-04-03 14:35:54 »

Hey if we are talking coding conventions lets have a fight about the evils of misplaced parenthesis :-)

I hate Sun's 'standard' way.. I like my {} aligned...
1  
2  
3  
4  
if( blah )
{
    woo(hoo);
}


I've seen some odd alternatives too.. like..
1  
2  
3  
4  
if( blah )
    {
    ew(yuk);
    }


And if I had to name them, I would call them Floyd Cheesy.

Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #16 - Posted 2003-04-03 14:52:31 »

Quote
I hate Sun's 'standard' way.. I like my {} aligned...


Damn straight, skippy!

Java Game Console Project
Last Journal Entry: 12/17/04
Offline cfmdobbie

Senior Member


Medals: 1


Who, me?


« Reply #17 - Posted 2003-04-03 15:42:01 »

Me too! Grin

I like my braces aligned, all apart from in two situations, where I prefer them "split":

1  
2  
3  
4  
5  
String[] filenames = {
      "foo.txt",
      "baa.rgb",
      "quux.tar.gz"
} ;

1  
2  
3  
4  
5  
6  
f.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e)
      {
            // Code in here
     }
}) ;


I suppose this is because it avoids a hanging equals symbol in the first, and makes the point that it's an inline class definition in the second.  It just seems right in those two situations.

How about asking whether there's a space before the semi-colon at the end of a statement, spaces immediately padding out parentheses, single-line if/for/do/while constructions with or without braces... Grin

(BTW: yes/no/without)

Hellomynameis Charlie Dobbie.
Offline jbanes

JGO Coder


Projects: 1


"Java Games? Incredible! Mr. Incredible, that is!"


« Reply #18 - Posted 2003-04-03 15:48:30 »

if((data = in.read()) >= 0) out.write(data);

Extra spaces take up more width without giving back much readability IMHO. Of course, that's one of those minor points that I'm usually pretty flexible on.

Java Game Console Project
Last Journal Entry: 12/17/04
Offline Breakfast

Senior Member




for great justice!


« Reply #19 - Posted 2003-04-03 18:41:57 »

Damn right about the aligned parenthesis. I thought I was the only person who thought the open bracket after the declaration looks stupid.
Offline Matzon

JGO Knight


Medals: 19
Projects: 1


I'm gonna wring your pants!


« Reply #20 - Posted 2003-04-03 18:49:35 »

Quote
I thought I was the only person who thought the open bracket after the declaration looks stupid.

No there are a couple of you  Tongue

Offline Ceranith

Senior Newbie





« Reply #21 - Posted 2003-04-03 21:19:20 »

Quote

No there are a couple of you  Tongue

Yeah, one more here Tongue
Offline Harley Rana

Junior Member




Java games rock!


« Reply #22 - Posted 2003-04-04 00:25:12 »

Ive beeing learning and looking at more c++ lately, and the styles have really rubed off on me.  Like next line braces, and more use of abbrivated variable/class names.  But still havn't picked up hungarian notation, which is so common.

I think using abbrivations can be overused, but there are some cases where it works.  Like when the meaning is clear, and its used all over the place, like vectors. Smiley

Regularly i thank the kind souls that gave us eclipes, and its code formater.  I never would have been able to make an inner listener with out them.  Cheesy
Offline Harley Rana

Junior Member




Java games rock!


« Reply #23 - Posted 2003-04-04 00:30:05 »

While we are talking formating, what is style comments do you like? Smiley

Im thinking more for personal readability than java doc compliance.
Offline GergisKhan

Junior Member




"C8 H10 N4 O2"


« Reply #24 - Posted 2003-04-04 12:37:33 »

Jumping in late, but....

I don't care for non-aligned braces at all.  I WANT to see my code blocks, and virtually every editor I have used does some form of highlighting if you put the cursor at one brace or another (even vi does this, just hit % and it takes you to its pair).

As for spacing, I'm a spacing freak.  I prefer spaces before parenthesis, except for class cast like this:

temp = (Image) vImages.next();

if ( temp != null )
{
  // Do something here
}

And no space when there's nothing between the ().

Comments?  What are those???? *evil grin*  (For me, I just like straight javadoc, or a // one liner for explanation.)

Further question:

who likes their variables aligned, and what convention do you use?

1  
2  
3  
int                                                      x;
Object           y;
DataBuffer  z;

gK

"Go.  Teach them not to mess with us."
          -- Cao Cao, Dynasty Warriors 3
Offline Breakfast

Senior Member




for great justice!


« Reply #25 - Posted 2003-04-04 12:47:45 »

I don't align the variables, that seems a bit excessive, but I am quite careful to always declare the same types together.

I find that I don't usually need much more than the javadoc comments- as long as you keep methods short, splitting the really long ones up if necessary, you can usually work out what is going on. And For some reason I find going back through my own Javadocs quite satisfying. I don't know why.
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #26 - Posted 2003-04-04 21:00:50 »

I sometimes align variables that are related, with spaces, so tab sizes don't bugger them up.  It depends on how different the 'type' identifiers are in length too.. if the variable name will get 'hidden' in a crevice I add spaces to pull it out. e.g. in:
1  
2  
3  
MegaBlasterLevel level;
int score;
SuperDuperSpaceShip ship;

I would push 'score' out to line up with 'level'

Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #27 - Posted 2003-04-04 22:50:37 »

Quote
Hey if we are talking coding conventions lets have a fight about the evils of misplaced parenthesis :-)

I hate Sun's 'standard' way.. I like my {} aligned...
1  
2  
3  
4  
if( blah )
{
    woo(hoo);
}


I've seen some odd alternatives too.. like..
1  
2  
3  
4  
if( blah )
    {
    ew(yuk);
    }


And if I had to name them, I would call them Floyd Cheesy.


i used the 2nd style for some years. switched awhile ago to the first one, cuz it was much easier to type with textpad :>

if i had to name em, i would call em block-style A and block-style B. sounds cold and techie doesnt it? =)

"sun's way" is called "hugging brackets" (or summin like that)... dunno i hate it too Smiley

and names for other stuff... mh...

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
int bs = 0; //bonus sprite (-1 = level up | 0 = none | 1 = full fuel/health)
int bsX=666; //out of sight
int bsA=0; //animation (blink 0/1)
int bsY=60;
//explosion
int[][] exx=new int[MAX_STUFF][3]; //x,y,age
int ex=0;
//heli
int[][] hh=new int[MAX_STUFF][3]; //x,y,d
int h=0;


somewhat scary isnt it? :>

弾幕 ☆ @mahonnaiseblog
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #28 - Posted 2003-04-04 22:59:54 »

Quote
[...]
I would push 'score' out to line up with 'level'


it would look better but it wouldnt increase readability (imo).

1  
2  
3  
4  
5  
6  
7  
8  
9  
g.fillRect(0,  0,640,60); //top
g.fillRect(0,420,640,60); //bottom
[...]
for(x=0;x<MAX_STUFF;x++)
{
      pp [x][1]= 0; //move projectiles out of sight (-1 Y-shift)
     exx[x][2]=62; //move explosions out of sight (<62 check)
     hh [x][1]= 0; //move helis out of sight (=0 check)
}


in this two cases it makes more sense. u can read it much better, cuz the values wich have summin in common are next to each other.

btw that r parts from my highly ineffective 4k game, wich isnt finished yet :>

弾幕 ☆ @mahonnaiseblog
Offline erikd

JGO Ninja


Medals: 16
Projects: 4
Exp: 14 years


Maximumisness


« Reply #29 - Posted 2003-04-11 07:06:09 »

For what it's worth, I learned to like the 'sun' way of brackets although I really hated it at first.
It makes the code more compact while keeping readability and sometimes even enhances it in case of larger functions (I like keeping an overview and I hate scrolling through code).
In fact I like the sun conventions in general.


Pages: [1] 2
  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.

Nickropheliac (14 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (29 views)
2014-08-22 19:31:30

atombrot (41 views)
2014-08-19 09:29:53

Tekkerue (38 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (24 views)
2014-08-16 06:20:21

Tekkerue (34 views)
2014-08-16 06:12:11

Rayexar (72 views)
2014-08-11 02:49:23

BurntPizza (48 views)
2014-08-09 21:09:32
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!