#Please review my Snake clone

3 messages · Page 1 of 1 (latest)

willow pivot
silver relic
#

Looks quite good. One small thing I see is that you use brackets for empty structs Apple{} but you can use just Apple, no need for the brackets(both, when declaring and when instancing). Second thing is a total nitpick and can be just personal taste but I find your line breaking hard to read and it confused me in a few places to the point I really had to focus on the code to understand what is happening. You are doing breaks like this: rs let (snake_segment_translation_x, snake_segment_translation_y) = board.get_translation(snake.array[i]);
I would suggest breaking them in a way that next line clearly shows that it belong to the previous one. That way you can train your brain to parse it automatically. Without it, you need to pause and look at the end of the line to see that equal sign to understand it's a continuation, wasting much more of your attention and brain power 🙂 In this case I would break it over the dot, like this: rs let (snake_segment_translation_x, snake_segment_translation_y) = board .get_translation(snake.array[i]);
It applies to other situations as well, for example break conditions with operators at the front: rs if some_very_long_conditions_1_really_long && some_other_very_long_condition
When reading code and quickly looking for something, we focus on the beginings of the lines and putting additional information speeds you up. If you put it at the end, you have to move your eyes to the end to parse it. By putting it at beginning you basically make it to act as additional visual cues to help you navigate your code 🙂

willow pivot
#

Ok, thanks, I'll be more mindful of that next time. I was just letting the autoformatter format my code tbh. I would also find it confusing so I need to look into my autoformatter settings and configure it so it doesn't do that.