bevy_ecs_dynamic icon indicating copy to clipboard operation
bevy_ecs_dynamic copied to clipboard

Better struct names in `reflect_value_refs.rs`

Open Escapingbug opened this issue 3 years ago • 2 comments

This is sort of an advice. I'm not sure if this is just for me or for anyone else. While reading the code from bevy_mod_js_scripting that references this repo, I found the struct names hard to understand. I followed the definitions here and found the xxRef quite frequently used. Since Rust also got the defined name reference, this names confused me a bit. Also, there are names like EcsBase which from the name only without context that you might think that is the base for ECS or something.

Since those structs are public, we might need better names so their semantics can be more clear.

Escapingbug avatar Oct 17 '22 01:10 Escapingbug

Yeah, it'd take some thought to come up with better names for them I think.

The xxRef types actually do refer ( aka. reference ) to values stored in the world, so they very much do act like a kind of reference.

I admit some of the names seemed a little ambiguous, but for a lot of them, I couldn't come up with anything that was necessarily better.

zicklag avatar Oct 20 '22 01:10 zicklag

I agree with everything zicklag said.

My reasoning is that the *Ref types can be though of as references to ecs values, because they don't contain the actual values, and when the underlying value is changed by someone else the reference instantly reflects that. And the EcsBase name I used because I think of the ReflectValueRef as a "base + offset", where the base is either a component or a resource and the offset is some reflect path like [0].translation.x.

That said, I definitely understand that these names can be confusing, and if you have any suggestions I will consider renaming them.

jakobhellermann avatar Oct 24 '22 20:10 jakobhellermann