[ACE] Constant variables in core scripts

(Sorry if I'm posting to the wrong place, it is named "Support")

Hello,

I am almost new to the world of RGSS3, but not to world of programming (I know other languages, like C, Python...)

So, I was looking at the core scripts (by that I mean Scene_Base, Game_Troop and other built-in scripts) and saw many functions that return a constant.

Example :

Spoiler
def window_width

return 240

end
I was wondering, wasn't it more flexible by making a constant variable? Example :

Spoiler
WINDOW_WIDTH = 240
Why are the core scripts made like this?

Does RGSS3 have some memory issues?

KockaAdmiralac
Because you can override those functions with your own when adding scripts, and then decide yourself if the return should be a fixed number or calculated in whatever way.

With a constant definition, that value can't be changed dynamically during the game if a scripter decides to change that part of the engine.

A better example are the battlemembers - that is 4 in the default, defined similiar to your example.

With a constant, the number could be changed but then it'll be a new constant.

The way it is now there are scripts that redirect the number of battle members to a variable (for example), allowing the developer to increase the allowed party size during the game.
Ok, I understood that, but wasn't it more flexible with something like :

Spoiler
attr_accessor :battle_members = 4
Well, for once, because that doesn't work.


Also that's only harder to read, not more flexible. I know i tend to compress my code too much, but LoC (Lines of Code) shouldn't be a criteria for quality.
I actually think it is easier to read, but nevermind. That's just my opinion.

Ok, is there any other reason for defining functions that return variables rather than defining variables, except for readability?

If not, a moderator can close this topic.

Thanks for replying, Andar and Iavra!
What Andar means by extensibility is also that you could do this in a new class that inherits from Scene_Base:

def window_width contents.width + (horizontal_margin * 2)endThis means window_width can easily be modified to be dynamic.
Oh, I understand now.

Thanks! I will mark it as solved.
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/ace-constant-variables-in-core-scripts.41232/