New answers tagged

1

Let's start with readability. Without deducing from functionality, I have no idea what variables like s and ap, or what functions like create_s() and s_move() do. Use clear and obvious names; the common saying is that you would read a piece of code way more often than it is written, and it thus needs to be easy to understand---you might be surprised how ...


4

Const methods These: int posX() { return foodX; }; int posY() { return foodY; }; // ... int posX() { return headX; }; int posY() { return headY; }; int len() { return length; }; don't modify anything in this, so make them const: int posX() const { return foodX; }; int posY() const { return foodY; }; Setters This: void ...


Top 50 recent answers are included