iolivia / rust-sokoban

Rust Sokoban book and code samples
https://sokoban.iolivia.me
MIT License
155 stars 29 forks source link

Feedback: Confusing imports at interim stages of project #72

Closed danieldeankon closed 2 years ago

danieldeankon commented 4 years ago

I'm coming into this with a few months of Rust experience, but nearly no experience with making games or using an ECS.

While working through this project I found some of the presentation of imports confusing. For example, when going from chapter 01-01 to chapter 01-03 a whole bunch of new imports are added all at once. Not all of them are actually used at the chapter 01-03 stage of the project, so I was confused by why the unused ones were added. I'm using chapter 01-03 as one example, but it seems there are unused imports at most stages of the book.

I also found the structure of the import statements unclear, e.g. importing ggez, then importing ggez::graphics, then ggez::graphics::DrawParam, expecially when some lines later the more compact curly brace notation is used. The imports feel unexplained to me in general---I would like to know things such as: whether the imported elements are modules, functions, traits, structs, or enums, a brief summary of the imported elements, and finally why they are imported at the current stage of the project. The first two questions are answered to an extent by the documentation on the crates themselves, so I feel that answering the third question here is most important.

Speaking more generally about the book itself, it is pretty good. I found it a useful exercise to go off the book's track at various places and implement my own additions to the sokoban game---the book provides enough detail to enable this. I'd like to know more about why games use ECS so often, as I do not know what kinds of problems come up that ECS is introduced to solve.

iolivia commented 4 years ago

hey @danieldeankon! thanks for the feedback!

Unused imports I agree the imports are confusing, especially unused imports. They are there because code moved around in the starting stages of the book and code samples ended up split between multiple chapters so some of the imports were kind of left behind. I've created #79.

Compact imports Yep, I think as a matter of style we should probably use compact imports throughout, created #80.

Explaining imports I think this is probably the least explained part, but I kind of did this intentionally. I wanted to leave a bit for whoever is following to have to figure out themselves, add/remove imports and try to understand why they are there. I think once we remove unused imports and unify the import style hopefully this one will be better.

I found it a useful exercise to go off the book's track at various places and implement my own additions to the sokoban game

This is great! What did you implement extra? I might add a few ideas throughout the book for people to try out.

I'd like to know more about why games use ECS so often

This is a great question. I kind of glossed over this on purpose since it's a really big topic. I think you certainly don't have to use ECS, it's entirely possible to do a game using inheritance or composition. For rust games specifically, I have found ECS to be easier to work with the borrow checker.

danieldeankon commented 4 years ago

My additions were:

I also partially implemented differently-coloured boxes and spots before actually reading that section of the book.