• 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
tom_mai78101

You became a programmer anarchist. What are some conventions that you don't want to follow along?

27 posts in this topic

Conventions are put in place so that others will know what were defined correctly. All is good when one follows the conventions. But what if one doesn't? Surely, if there's a good side, there has to be a bad side.

Seeing a giant switch..case code? Convert them all to if...elsif...else. Or replace all if...else to using a ternary operator.
See a function returning an integer? #define that integer as FUNCTION_RETURNING_VALUE, and set that in place.
See a small method? Add meaningless code that does nothing inside the method, to make it look like it's done professionally. (Works nicely with VS C++ compiler, as they optimize code upon building the codes. All meaningless codes will be erased from build.)
Have a meeting? Be a badass. :D

Defying the conventions sounds fun, but intrusive to the industry. So, the inner child of me have mixed feelings about this.
0

Share this post


Link to post
Share on other sites
When you're working with multiple people on the same code, standardized coding conventions are a good way to boost team productivity.

When you're writing code which needs to be maintained months or years down the road, having a coding standard and consistency [i]is a good thing[/i]!

There is a good reason for having and following conventions :) I think coding used to be a rather chaotic discipline and from that chaos, via the forces of evolution, emerged the best conventions and practices we use today. To return to the chaos would seem counter-productive...
0

Share this post


Link to post
Share on other sites
The bad side of conventions is fanatics following them when they're not appropriate or simply obsolete. Or people arguing over brace style conventions, seriously, just pick one already, rand() % 2 if you need to! (Allman ftw, scraping lines to get more code on the screen is so 20th century, lol)
0

Share this post


Link to post
Share on other sites
I used to work at a place that had extremely strict commenting conventions, where every single function had to be commented with... [b]the name of the function[/b], the date it was added, and the original author... and optionally what it does.
During a crunch period I got sick of it and started writing code like:
[code]/*--------------------------------------
* Function: DrawShadows
* Date: 12/34/56
* Author: Hodgman
* Comment: This actually erases the save games, it's just really badly named. No, really. don't call this to draw shadows.
*------------------------------------*/
void DrawShadows()
{
...code to draw shadows...
}[/code]
0

Share this post


Link to post
Share on other sites
If you want to be an anarchist...

Make sure you adhere to no naming convention... use getName(), name(), Name() interchangeably
Use var, mVar, m_var,m_Var and various Hungarian things interchangeably, preferably within the same class
Refuse to use source control
Refuse to wait for code review or testing, throw your changes ad-hoc onto live systems and of course don't document it
0

Share this post


Link to post
Share on other sites
I do not follow capitalization conventions in Java.
Any useless variable, that is mandatory to have in code, is named "X" ( Such as in LSL )
Python purists have a fit every time they read my code examples, as I tend to compact code and throw the entire [url="http://www.python.org/dev/peps/pep-0020"]Python Mantra[/url] out the window.
0

Share this post


Link to post
Share on other sites
[quote name='d000hg' timestamp='1349364921' post='4986793']
If you want to be an anarchist...

Make sure you adhere to no naming convention... use getName(), name(), Name() interchangeably
Use var, mVar, m_var,m_Var and various Hungarian things interchangeably, preferably within the same class
Refuse to use source control
Refuse to wait for code review or testing, throw your changes ad-hoc onto live systems and of course don't document it
[/quote]

Don't forget to use different types of white space and following whitespace.

Add comments above, below, before, after, and sometimes in the middle of lines of code, but never following any set standard.

[source lang="csharp"]
//Why would someone do this?
public void /*because...*/ somefunction(blah blahblah) // fuck you!
//... that's why.
[/source]
0

Share this post


Link to post
Share on other sites
I don't like this
[CODE]
if(..) {
}
[/CODE]
I prefer
[CODE]
if(..)
{
}
[/CODE]
Looks more structured to me.

I also don't like white space everywhere. Like
[CODE]
if ( bla ) {
do ( bla );
}
[/CODE] Edited by froop
0

Share this post


Link to post
Share on other sites
[quote name='froop' timestamp='1349377057' post='4986841']
I also don't like white space everywhere.
[/quote]
[CODE]
if((doSomething(stuff,moreStuff)&&!didSomethingAlready)||(didSomethingAlready&&noNeedToDoMore&&overrideAlreadyDidSomething(manager.name.c_str())))
[/CODE]
Yup, much nicer. Seriously, I have seen stuff like this in code. And yet they wondered why so often bugs appear. Being an anarchist and breaking all rules may be fun to do for a bit, trying to get up with a working program that abuses operator overloading like mad and consists of code that when you look at it looks like a pacman made of code and whitespace. But mostly guidelines are there for a reason. Of course, they are guidelines for a reason as well, break them if you have to, but you need to be able to defend your decision to break them. Edited by MichaBen
0

Share this post


Link to post
Share on other sites
[quote name='froop' timestamp='1349377057' post='4986841']
I don't like this
[CODE]
if(..) {
}
[/CODE]
I prefer
[CODE]
if(..)
{
}
[/CODE]
[/quote]
Been there... done it... got used it... makes no difference to me anymore...

[quote name='froop' timestamp='1349377057' post='4986841']
I also don't like white space everywhere. Like
[CODE]
if ( bla ) {
do ( bla );
}
[/CODE]
[/quote]
[quote name='MichaBen' timestamp='1349378363' post='4986846']
Yup, much nicer. [...]
[/quote]
Yes, I do agree, white spaces are YOUR FRIEND! However, liking this (i.e. the stated example
[CODE]
if ( s == o ) {
}
[/CODE]
) is just WRONG! (ok, ok, it's all about opinions...) But, this is just something that *every single* coding convention I have ever used with agrees with (including the "official" Java and C# styleguides). The only people (at the place I work) that write like this are mathematicians that should not touch the code. PERIOD!!! (yes, I am getting carries away, but it's the truth!) It's got to look like this:
[CODE]
if (foo == bar) {
// there's what do do if foo equals bar
}
[/CODE]
(and yes, I've seen very f'ed up coding conventions... ;) )


...

And, to stay on topic (although, I don't quite get it)... this is something evil to do:
[CODE]
#define TRUE FALSE //Happy debugging suckers
[/CODE]
Some fun (most will already now it, but I like to read it once in a while): [url="http://stackoverflow.com/questions/184618/what-is-the-best-comment-in-source-code-you-have-ever-encountered"]http://stackoverflow...ver-encountered[/url]


// way too many edits... time to go to bed... Edited by brx
0

Share this post


Link to post
Share on other sites
I tend to stick with what the majority of people in the language use. That means:

C#
[code]
if(true)
{
// stuff
}
[/code]

Javascript
[code]
if(true) {
// stuff
}
[/code]

CSS
[code]
.selector {
/* style! */
}
[/code]
0

Share this post


Link to post
Share on other sites
[quote name='CryoGenesis' timestamp='1349381144' post='4986862']
Setters and getters. Why, just why?
[/quote]Go read a book and find out.
0

Share this post


Link to post
Share on other sites
Fucking Hungarian notation will kill me. Fuck that, and fuck that to hell. Underscores are also pain in the ass.
[code]
private:
int _omg;
int __uberomg;

int some_stupid_calculation = __uberomg + _omg * __uberomg / __uberomg + __othervar + __more_private_variable + __underscore;

[/code]
0

Share this post


Link to post
Share on other sites
[quote name='CryoGenesis' timestamp='1349381144' post='4986862']
Setters and getters. Why, just why?
[/quote]
That's easy!
Setters... because they sometimes do good stuff (i.e. bound checks, assertions, etc)!
Getters... because if the setters do good stuff, you just can't make the member public! Edited by brx
0

Share this post


Link to post
Share on other sites
[quote name='brx' timestamp='1349382073' post='4986872']
[quote name='CryoGenesis' timestamp='1349381144' post='4986862']
Setters and getters. Why, just why?
[/quote]
That's easy!
Setters... because they sometimes do good stuff (i.e. bound checks, assertions, etc)!
Getters... because if the setters do good stuff, you just can't make the member public!
[/quote]

Getters are also useful for lazy evaluation / data fetching. In C# you can also change the visibility of getters / setters independently.

[code]public int SomeValue { get; private set;}[/code]

You now have a member property that is read-only outside of the base class.
0

Share this post


Link to post
Share on other sites
Setters and getters: Because they can be virtual in most languages. In C# they can have public get/protected set (as stated above) and also be specified as part of an interface. Edited by Nypyren
0

Share this post


Link to post
Share on other sites
[quote name='alnite' timestamp='1349382031' post='4986871']
Fucking Hungarian notation will kill me. Fuck that, and fuck that to hell. Underscores are also pain in the ass.
[code]
private:
int _omg;
int __uberomg;

int some_stupid_calculation = __uberomg + _omg * __uberomg / __uberomg + __othervar + __more_private_variable + __underscore;

[/code]
[/quote]

It wouldn't surprise me, but do you really have to deal with multiple levels of underscores? Typically underscores don't bother me, and they provide a nice side effect of showing all private variables in intellisense when you type _. I see them a lot less frequently now that we have auto-implemented getter / setter support in C#.
0

Share this post


Link to post
Share on other sites
Ok, I'll throw this out there. While not a coding convention... I find unit tests to be highly overrated. Their biggest benefit is actually just forcing you to think about how your code is going to be used. From that perspective they are great, but you should be thinking about your code's clients anyway! In the end you have a huge number of tests which is supposed to protect you when refactoring, but chances are if you're doing any significant refactoring chances are you'll have to overhaul your unit tests as well.

Furthermore, unit tests don't prevent the type of errors I encounter most in software projects I'm working on. Integration tests do. Testing how separate systems interact and communicate has been far more valuable to me than unit tests have been.
0

Share this post


Link to post
Share on other sites
[quote name='MichaBen' timestamp='1349378363' post='4986846']
[quote name='froop' timestamp='1349377057' post='4986841']
I also don't like white space everywhere.
[/quote]
[CODE]
if((doSomething(stuff,moreStuff)&&!didSomethingAlready)||(didSomethingAlready&&noNeedToDoMore&&overrideAlreadyDidSomething(manager.name.c_str())))
[/CODE]
Yup, much nicer. Seriously, I have seen stuff like this in code. And yet they wondered why so often bugs appear. Being an anarchist and breaking all rules may be fun to do for a bit, trying to get up with a working program that abuses operator overloading like mad and consists of code that when you look at it looks like a pacman made of code and whitespace. But mostly guidelines are there for a reason. Of course, they are guidelines for a reason as well, break them if you have to, but you need to be able to defend your decision to break them.
[/quote]
There should be spaces between non-unary operators and after commas, but there should not be a space after an opening bracket nor before a closing one. Just like in typography. The case of wrapping an unary operator like negation between brackets is arguable, it's a common mathematical convention that unary operators take precedence over just about anything else, but this can be violated in programming languages with preprocessor rules, prefix/postfix operators, or other stuff. Thus:
[source lang="cpp"]if ((doSomething(stuff, moreStuff) && (!didSomethingAlready)) || (didSomethingAlready && noNeedToDoMore && overrideAlreadyDidSomething(manager.name.c_str())))[/source]
You can also use newlines to make the || operator terms more visible, or even break the condition into two different conditions based on didSomethingAlready. Or just use shorter function names and less conditions.There is always a solution.

People who put redundant brackets with extra spaces inside them and before semicolons, and deliberately omit spaces around assignment operators drive me insane! I see this kind of code all the time in VB and Java code for some reason:
[source lang="cpp"]if( ( myCondition )==MY_DEFINE ){return ( ~myCondition*2+(1+1) ) ;}[/source]
[img]http://public.gamedev.net//public/style_emoticons/default/sad.png[/img] Edited by Bacterius
0

Share this post


Link to post
Share on other sites
Stop using data structures. Instead, just make a function that takes a bajillion arguments. Example:

[code]
// Used to be:
const Image combine(const Image& image1, const Image& image2)
{
...
}

// So now it's:
void combine(const char* buf1, int width1, int height1, int pixelFormat1, const char* buf2, int width2, int height2, int pixelFormat2, char* outBuf, int& outWidth, int& outHeight, int& outPixelFormat)
{
...
}
[/code]

I'm not entirely sure what the point of this thread is, so this is me guessing like I'm playing along.
0

Share this post


Link to post
Share on other sites
How about you upload a virus that's sorta like in Superman 3. Just be sure and watch the decimal places, or you might have a sudden attack of conscience and start working in construction.
0

Share this post


Link to post
Share on other sites
P.S. Anachism != chaos, deliberate rebellion against rules.
Anarchism == rejection of central authority/acknowledgement of individual authority and voluntary rule abidance with no monopoly on power.

Anarchist programmers would probably still voluntarily adhere to decent guidelines ([i]because they're beneficial to projects[/i]), but anyone would be free to participate in the guideline forming process, or democratically propose an alternative set of guidelines, instead of some arbitrary manager forcing the decisions down the hierarchy [i]a la[/i] dictatorship style.

Valve [url="http://newcdn.flamehaus.com/Valve_Handbook_LowRes.pdf"]is basically[/url] an anarchist games company. Edited by Hodgman
0

Share this post


Link to post
Share on other sites
[quote name='alnite' timestamp='1349382031' post='4986871']
Fucking Hungarian notation will kill me. Fuck that, and fuck that to hell. Underscores are also pain in the ass.
[code]
private:
int _omg;
int __uberomg;

int some_stupid_calculation = __uberomg + _omg * __uberomg / __uberomg + __othervar + __more_private_variable + __underscore;

[/code]
[/quote]

double underscores make me sad :(
0

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