Rooms in setting.py in oTree

62 Views Asked by At

I have a quick question about setting rooms in oTree. This can be perhaps silly but I am a bit confused. I have set up one room for my experiment in oTree hub and hence one room in settings.py file. If I add only one room, then should it be ROOM instead of ROOMS?

1

There are 1 best solutions below

1
Poza On

Most likely, the reason it says "ROOMS" instead of "ROOM" is - as with "PARTICIPANT_FIELDS," "SESSION_FIELDS" etc. - to avoid unnecessary coding. It's a variable not shown to the participants, so there is no need to differentiate in its name whether it contains only one or more rooms. In fact, we would even need two variables if we wanted to, and all the code that refers to them would need to take both variables into account. This introduces unnecessary complexities.

Plus: See this article on the naming of variables:

There are a few different rules for crafting clean variable names. Singular nouns should be used to name variables that store primitive type values and object references. Using a singular noun, more clearly indicates that the variable only contains one value. Plural nouns should be used to name variables that store arrays or other collections. Using a plural noun, more clearly indicates that the variable contains multiple values."