JuliaReinforcementLearning / CommonRLInterface.jl

A minimal reinforcement learning environment interface with additional opt-in features.
MIT License
45 stars 1 forks source link

With or without `get_` prefix? #13

Closed findmyway closed 4 years ago

findmyway commented 4 years ago

Though I use C# & Java a lot at work. I hate the get/set stuff 😠 . But in some cases, I find they reduce some naming headaches.

Let's say we want to define a state(env) function to get state from an environment. But state itself is just a noun and people (including me) may write

state = batch.state  # init the state
Q(state, action)
# now I want to get the state in env, bang, error...
next_state = state(env)

And the similar goes for actions and some other methods.

XRef: https://github.com/JuliaReinforcementLearning/CommonRLInterface.jl/issues/8#issuecomment-645645483


👍 = add get_ prefix 👎 = without get_ prefix

MaximeBouton commented 4 years ago

I think get_ is not very Julian. It is much more elegant to be able to call state(env) than get_state(env). I agree that sometimes it is annoying but I personally think it is worth it. In the example you gave I would typically use s as a variable name. Also batch.state could be state(batch). On other Julia project, I found that relying on fieldnames was harming composition with other packages.