Feedback
Closed this issue ยท 2 comments
podondra commented
Hi @hroncok and @MarekSuchanek.
I've just finished the WaTor assigment and add tag v0.1 to the right commit. Therefore, I would like to ask for feedback please.
Thanks.
hroncok commented
- ๐ test all pass for me
- ๐ฉ flake8 is silent
The rest are nitpicks. Giving 5 points.
- ๐ when raising exceptions, you rise the exception class (
raise(ValueError)
)- there's no information for the user, instead raise an instance with a message, such as:
raise ValueError('cannot use energies and energy_initial together')
- ๐ฅ I didn't even know raising classes is possible
- ๐๏ธ this will also make your code more readbale (i.e. I don't have to decrypt: why is this exception here?)
- there's no information for the user, instead raise an instance with a message, such as:
- ๐ฏ I like the way you did the random creatures setup
- ๐ but on the other hand, your
__init__
is rather long and if I didn't know what is supposed to happen, I would have to decipher it to understand it, breaking it to smaller methods with descriptive names would make it more readable (i.e.__init__
calls something likeself._random_creatures(...)
) - ๐
generate_move
is very Pythonistic using generators, which is good, but it will kick you a bit when we iterate to Cython - so prepare for more fun ๐ฟ - 2๏ธโฃ you copy creatures twice per chronon, which might not be very effective