Favourite name for vectors?

[quote]I thought I was the only person who thought the open bracket after the declaration looks stupid.
[/quote]
No there are a couple of you :stuck_out_tongue:

Yeah, one more here :stuck_out_tongue:

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. :slight_smile:

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. :smiley:

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

Im thinking more for personal readability than java doc compliance.

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?


int                                                      x;
Object           y;
DataBuffer  z;

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.

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:


MegaBlasterLevel level;
int score;
SuperDuperSpaceShip ship;

I would push ā€˜score’ out to line up with ā€˜level’

[quote]Hey if we are talking coding conventions lets have a fight about the evils of misplaced parenthesis :slight_smile:

I hate Sun’s ā€˜standard’ way… I like my {} aligned…


if( blah )
{
    woo(hoo);
}

I’ve seen some odd alternatives too… like…


if( blah )
    {
    ew(yuk);
    }

And if I had to name them, I would call them Floyd :D.
[/quote]
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 :slight_smile:

and names for other stuff… mh…


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? :>

[quote][…]
I would push ā€˜score’ out to line up with ā€˜level’
[/quote]
it would look better but it wouldnt increase readability (imo).


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 :>

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.

I am with the ā€œblockā€ crowd, much easier to read, esp. since I don’t use {'s for on-line ifs

if(b)
foe(x,y,z);

Mix that with the mis-aligned braces and things gets horribly complicated.

I align variables (both members and local).

I keep members at the beginning of the class and always prefix with ā€œm_ā€ - statics are prefixed with g_ and static final (constants) are all caps. (simple data-classes with no code and public fields don’t have the m_)

I use i-prefix for integers (of all sizes), x for fixed point, f for floating points (float and double), a for arrays, v for vectors, s for strings. Other types are not prefixed. I occasionally stray from this (for example when using i, x, y, z etc. in loops and for local variables).

My vector class is an interface called Vec (and Vec2, Vec3 etc. for various impl.)

Upper-case first char in class names, lower case in methods and variables.

I don’t use the I and C prefix on Interfaces/classes commonly used in C++ as I don’t feel the need for that in Java (besides, my IDE clearly indicates which is what so I don’t need it).

Oh, and I prefer grey background in my editor. Comments in dark-grey so they don’t clutter the important part - the code :wink: …

I do

if (b) foo(x,y,z);

Again, a lot more compact which makes the code generally easier to understand for me :slight_smile:

[quote]Oh, and I prefer grey background in my editor
[/quote]
I prefer black girls. ::slight_smile:

Ah well, it’s all just a matter of personal taste and habit I suppose :slight_smile:

Hi,

No one talked about labels :wink:
I’m used to name all of them deCadix, because of the French song http://membres.lycos.fr/chezthal/luismariano/labelledecadix.html :smiley:

And for other variable names, I follow the Disney characters recommendations from this thread http://forum.java.sun.com/thread.jsp?forum=4&thread=341770. ;D