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

Your Worst "Gotchas" ever in programming

69 posts in this topic

Semicolons are just as easy to miss even if you put the brackets in a different line.

 

You guys should seriously upgrade your language and tools!

 

Screen%20Shot%202013-02-12%20at%207.41.3

 

Notice the squiggly under the semi-colon, and under something. Also notice that the code inside of the brackets is greyed out. That's because the tools are smart enough to detect that the code inside the brackets is never executed. 

0

Share this post


Link to post
Share on other sites

Semicolons are just as easy to miss even if you put the brackets in a different line.

QFT, happened once or twice to me.
The good thing is that those kind of mistakes (with infinite while loops) are very easy to debug!
The bad thing was, I didn't yet know how to use a debugger. tongue.png

 

@tstrimple: Sadly, my IDE of choice doesn't do that. sad.png

(I use QtCreator, which is fairly modern, and includes alot of C++11 syntax highlighting for things like lambdas and such)

Edited by Servant of the Lord
0

Share this post


Link to post
Share on other sites

Macros with more lines and semicolon? Used and a bracket-less one liner in if/for/whatever statements? Got me once. I had to come here with it then feel the facepalms

0

Share this post


Link to post
Share on other sites

For me it was before I learnt the use of arrays, I used to declare every variable independantly and used copy/paste a lot, I lose track of the number of times I forgot to change a number and had two values trying to store in the same variable. One simple number cam cause so many issues.

0

Share this post


Link to post
Share on other sites

The good thing is that those kind of mistakes (with infinite while loops) are very easy to debug!

Then you do it with an if statement and you go crazy as the program behaves strange and you can't tell why. Even worse is if instead of behaving strange it ends up behaving exactly the same as the previous build... You'll go insane trying to figure out what did you forget to make the condition true.

 

Also reminds me, somebody I know says that you should always get somebody else to look at your code because you will always read what you intended to write, not what you actually wrote.

0

Share this post


Link to post
Share on other sites

Semicolons are just as easy to miss even if you put the brackets in a different line.

 

You guys should seriously upgrade your language and tools!

 

Screen%20Shot%202013-02-12%20at%207.41.3

 

Notice the squiggly under the semi-colon, and under something. Also notice that the code inside of the brackets is greyed out. That's because the tools are smart enough to detect that the code inside the brackets is never executed. 

 

Is this VS 2012? It looks like C#.

0

Share this post


Link to post
Share on other sites

 

Semicolons are just as easy to miss even if you put the brackets in a different line.

 

You guys should seriously upgrade your language and tools!

 

Screen%20Shot%202013-02-12%20at%207.41.3

 

Notice the squiggly under the semi-colon, and under something. Also notice that the code inside of the brackets is greyed out. That's because the tools are smart enough to detect that the code inside the brackets is never executed. 

 

Is this VS 2012? It looks like C#.

 

I did say language and tools. ;)

 

Yes, VS 2012.

0

Share this post


Link to post
Share on other sites
Default arguments are fucking evil.
struct Base
{
    Base(int value1, int value2, int* pvalue3 = NULL);
};

struct DerivedOne
{
    DerivedOne()
        : Base(1, 2, NULL)
    {  }
};

struct DerivedTwo
{
    DerivedTwo()
        : Base(3, NULL)
    {  }
};
Spot the bug.
0

Share this post


Link to post
Share on other sites

It looks like C#.

 
I did say language and tools. ;)

 

Oh, don't worry on that account, we already upgraded our language. wink.png 
Which, incidentally, also solves ApochPiQ's bug in the post above this.

Edited by Servant of the Lord
0

Share this post


Link to post
Share on other sites

I did say language and tools. ;)

That the language still allows you to make that exact same mistake in exactly the same way doesn't make it look like an upgrade =P

0

Share this post


Link to post
Share on other sites

I did say language and tools. ;)

That the language still allows you to make that exact same mistake in exactly the same way doesn't make it look like an upgrade =P

 

 

True, the tools for the language are what's better. 

Edited by tstrimple
0

Share this post


Link to post
Share on other sites

Oh gee.

  • Anything threading
    • Implementing a reusable, thread-safe, intrusive copy-on-write base for classes (2 levels of thread safety required!!)
    • Any undocumented or hard to find caveat to a windows api call. Ex: WatiForMultipleObjects in some threading situations
  • Different STL optimization flags set in a single project. This caused random crashes in random places I spent a looong time "debugging" in code which was actually correct.
  • MSVC producing the same .obj filename out of two separate source codes in separate directories which themselves have the same filename. UGH. Major linking problems.
  • C++ implicit casting has nailed me hard more than once.
0

Share this post


Link to post
Share on other sites

Oh, don't worry on that account, we already upgraded our language. wink.png 
Which, incidentally, also solves ApochPiQ's bug in the post above this.

Actually, the implicit NULL conversion to literal 0 in my code is a total red herring. The actual evil is squarely with default parameters, and can be trivially reconstructed even with all the parameters being of primitive non-pointer types.
0

Share this post


Link to post
Share on other sites

It looks like C#.

 
I did say language and tools. ;)

 
Oh, don't worry on that account, we already upgraded our language. wink.png 
Which, incidentally, also solves ApochPiQ's bug in the post above this.
You know, I'm sure with a higher than default warning level and 'warnings as errors' I've seen the compiler catch this error before now (reports as a warning, warning as error fails the compile).

Now, it won't catch you when you make this mistake...
auto it = std::begin(someContainer);
auto end = std::end(someContainer);
bool found = false;
while(it != end && !found)
{
    found = *it == searchItem;
}
Opps... biggrin.png
0

Share this post


Link to post
Share on other sites

@ApochPiQ: Then I fail, cause I can't spot it at all. laugh.png

(Ignoring the lack of actual inheritance in the structs, which I presume isn't the bug)

Edited by Servant of the Lord
0

Share this post


Link to post
Share on other sites
I'll rephrase it slightly:
struct Base
{
    Base(int oldValue, int newValueWeJustAdded, int oldValueWithDefault = 42);
};

struct EverythingMustBeOne : Base
{
    EverythingMustBeOne()
        : Base(1, 1, 1)
    {  }
};

struct EverythingMustBeTwo : Base
{
    EverythingMustBeTwo()
        : Base(2, 2)
    {  }
};
Assume that Extremely Bad Things™ happen if the value of oldValueWithDefault in EverythingMustBeTwo is not 2.
0

Share this post


Link to post
Share on other sites

You know, I'm sure with a higher than default warning level and 'warnings as errors' I've seen the compiler catch this error before now (reports as a warning, warning as error fails the compile).

Gcc requires -Wall and -extra to catch it. Clang catches it by default.

 

(incidentally, this discussion is occurring over here as well).

0

Share this post


Link to post
Share on other sites


Now, it won't catch you when you make this mistake...



auto it = std::begin(someContainer);
auto end = std::end(someContainer);
bool found = false;
while(it != end && !found)
{
    found = *it == searchItem;
}
Opps... biggrin.png

 

Lesson: stick to for loops when doing that kind of iterations.

0

Share this post


Link to post
Share on other sites

Lesson: stick to for loops when doing that kind of iterations.

I prefer the 'while' construct; imo it better expresses the intent of the loop.
'for' tends to imply you'll hit a whole range where 'while' is more a 'while these conditions are true' and, in my mind, is better for a search.

Would have prefered to have used an std algorithm however, would have been clearer and without the mistake...
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