• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Nercury

Academia

36 posts in this topic

The right balance depends on the scope of the variable. If you've got a 3-line loop body, with Vec3 p = blah.position; as the first line, then there's no problem, as further explanation about what 'p' means appears in the same context.
If someone has a member variable named 'p', then the class better be pretty damn simple/small/self-explanatory.
If someone has a global variable named 'p', they can GTFO ;-)

The larger the scope, the longer the appropriate name length.

 

Yeah, that sounds like a reasonable line of reasoning.

1

Share this post


Link to post
Share on other sites

The right balance depends on the scope of the variable. If you've got a 3-line loop body, with Vec3 p = blah.position; as the first line, then there's no problem, as further explanation about what 'p' means appears in the same context.
If someone has a member variable named 'p', then the class better be pretty damn simple/small/self-explanatory.
If someone has a global variable named 'p', they can GTFO ;-)

The larger the scope, the longer the appropriate name length.

 

Yeah, that sounds like a reasonable line of reasoning.

 

I think it's reasonably reasonable for you to say that his reasoning is reasonable.

2

Share this post


Link to post
Share on other sites

The reasonable amount of reasonably reasonable posts in this reasonable thread is reasonably reasonable.

 

...I dare you to read that sped up =P

0

Share this post


Link to post
Share on other sites

I think that everyone is being too reasona...oh what the crap, it isn't worth it.  I'm screwing it up.  This being reasonable stuff is becoming unreasonable!

0

Share this post


Link to post
Share on other sites

 

a random variable doing...nothing on the 4th line?

 

Well to be fair I have hand-picked the worst from this code, and this is just a beginning of the method.

 

 

That is clear and concise compared to alot/much of code Ive worked on in my professional career

 

Add some blanks spacings and carriage returns and some alignment/indentation  of common statement elements and tnat would be clearer than most of the Microsoft code Ive seen

 

Ive seen alot of code in 'books' that are the opposite spaced out rediculously

 

Just do what I do and take a library like that and put it through a 'pretty' printer program I wrote that reorgamizes the code to my own style (or do it by hand - seriously it wont take that long and you would get a readthrough of the code giving you some understanding of what the lib actually does)

---

 

 

as for variable names most of those usages are very tight minimal in their function  (let hear after you start having 8 way nested loops)

 

Now if they start having object class  with dozens of attributes or more obscure usage of the variables (besides initialization loops)  then longer names are warranted.

Edited by wodinoneeye
0

Share this post


Link to post
Share on other sites

I wouldn't say that using p as a name for verticle position variable is a coding horror, especially if it is some particle class with position (p), velocity (v) and acceleration (a), where the meaning is quite obvious. I personaly would use at least pos, vel, acc, but probably not the full text. Acceleration is so long to write...

 

Yea I know what you mean. I usually just write out the full name for my variables, with comments on what each of them are meant to be used for. Takes longer to type but helps me out in the end when coming back to my code to get myself up to speed.

0

Share this post


Link to post
Share on other sites
int      l, dijk, dijkl, dijkr, ima, qi, qj, qidiv, qjdiv, fi, fj, fijk2;
double   disx, disy, switchx, switchy, switchx2 ,disxl, disxr, disx2, disxr2;

dijk    = di + nx * (dj + oy * dk);
ima     = step_div(dk - ez, nz);
qj      = dj + step_int(-ima * byz * ysp);
qjdiv   = step_div(qj - ey, ny);
qi      = di + step_int((-ima * bxz - qjdiv * bxy) * xsp);
qidiv   = step_div(qi, nx);
fi      = qi - qidiv * nx; 
fj      = qj - qjdiv * ny,

fijk    = fi + nx * (fj + oy * (dk - ima * nz));

disy    = ima * byz + qjdiv * by;
switchy = (dj - ey) * boxy - ima * byz - qjdiv * by;

disx    = ima * bxz + qjdiv * bxy + qidiv * bx;
switchx = di * boxx - ima * bxz - qjdiv * bxy - qidiv * bx;



//This is what you would largely see after my usual treatment 
//(and I likely would add some extra parens around the multiplies 
//to emphasise the ordering

Does look a bit clearer after youve isolated the variable definitions (that partial list) from the calculation statements and added spacers to make the functions and variables more distinct.

 

Imagine how much more fun the above code would be with ALL  8+ char variable names  (and those function name would have to be expanded too --- wouldnt they ?....)

 

Short variable names dont bother me so much - but if there is anything weird/unusual  being done I will heavily comment to make clear some atypical code.

Edited by wodinoneeye
0

Share this post


Link to post
Share on other sites

Looks to me like an implementation of some paper. If you want your code to be easily understandable for someone who knows the paper, I guess this is not that bad style. One might want to add an underscore to express subscripts in TeX-style like in "d_ijk". Sure, you don't easily understand the code without knowing the source of the algorithm, but if you name your stuff to match names from the paper you're implementing, people will find it easier to verify your implementation against the paper...

 

If this code was written without a scientific paper as its background, well... that'd be bad ;-)

0

Share this post


Link to post
Share on other sites
int l,dijk=di+nx*(dj+oy*dk),dijkl,dijkr,ima=step_div(dk-ez,nz);
int qj=dj+step_int(-ima*byz*ysp),qjdiv=step_div(qj-ey,ny);
int qi=di+step_int((-ima*bxz-qjdiv*bxy)*xsp),qidiv=step_div(qi,nx);
int fi=qi-qidiv*nx,fj=qj-qjdiv*ny,fijk=fi+nx*(fj+oy*(dk-ima*nz)),fijk2;
double disy=ima*byz+qjdiv*by,switchy=(dj-ey)*boxy-ima*byz-qjdiv*by;
double disx=ima*bxz+qjdiv*bxy+qidiv*bx,switchx=di*boxx-ima*bxz-qjdiv*bxy-qidiv*bx;
double switchx2,disxl,disxr,disx2,disxr2;

WTF?!

 

I have never seen something so bad in my life when it came to horrid variable names and completely unreadable code. Seriously.

2

Share this post


Link to post
Share on other sites

int l,dijk=di+nx*(dj+oy*dk),dijkl,dijkr,ima=step_div(dk-ez,nz);
int qj=dj+step_int(-ima*byz*ysp),qjdiv=step_div(qj-ey,ny);
int qi=di+step_int((-ima*bxz-qjdiv*bxy)*xsp),qidiv=step_div(qi,nx);
int fi=qi-qidiv*nx,fj=qj-qjdiv*ny,fijk=fi+nx*(fj+oy*(dk-ima*nz)),fijk2;
double disy=ima*byz+qjdiv*by,switchy=(dj-ey)*boxy-ima*byz-qjdiv*by;
double disx=ima*bxz+qjdiv*bxy+qidiv*bx,switchx=di*boxx-ima*bxz-qjdiv*bxy-qidiv*bx;
double switchx2,disxl,disxr,disx2,disxr2;
WTF?!
 
I have never seen something so bad in my life when it came to horrid variable names and completely unreadable code. Seriously.

Theirs the thread that spawned the great gd.net horror experiment, suggest you check it out if you wanna see something truly horrible.
1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0