fastbook icon indicating copy to clipboard operation
fastbook copied to clipboard

general variable naming

Open radekapreel opened this issue 1 year ago • 0 comments

hey first of all - thank you very much for this course. I'm slowly going through it and I feel like a student again. Which has both good and bad sides, but it's great ;) The videos associated with the course are really helpful, I just have some small feedback about the code itself

one thing I noticed throughout all the examples is the lack of good naming practices, which could be very simply alleviated to make the course a lot more readable. My main two concerns are:

  1. redefining the same variable in multiple places
path = something
(...)
# a few sections down
path = something else

sometimes the same variable is reused over examples spanning multiple code blocks, sometimes it's simply overwritten in subsequent blocks. I'm no python specialist, but in any other language I used that would be deemed a bad practice

we could name them "bears_path", or "downloads_path" or whatever else makes sense in a given context

  1. short variable names. for example
trgts  = tensor([1,0,1])
prds   = tensor([0.9, 0.4, 0.2])

instead of

expected_targets  = tensor([1,0,1])
example_predictions   = tensor([0.9, 0.4, 0.2])

it really doesn't hurt to add those few characters more, but it makes it sooooo much easier if we don't have to decipher what the author meant. again - in any production grade project and in any company - short names like those would be considered bad practice. I think it's especially important here, because we're learning something new and we often don't yet have the experience required to decipher those short names correctly or efficiently.

some others are simply confusing without even giving us a fighting chance. example:

dset = list(zip(train_x,train_y))
x,y = dset[0]
x.shape,y

One would assume that x and y is a point on a 2d graph / in a matrix. Well, no. X is an image, and y is a label. Why not just call it that?

btw. some other examples

  • dls. Whenever I look at it I think "downloads", but "data loaders"
  • fns. This is "functions" more often than not. Here it's "file names"

I don't know if there is anyone checking those issues out, but hopefully this could make this course even better

cheers!

radekapreel avatar Feb 11 '24 15:02 radekapreel