What is the Benefit of this Order?

For the Update and ManageState Methods, what is the benefit of putting

“textComponent.text = state.GetStateStory();”

under ManageState vs under the Update method?

Hi,

It’s a matter of personal preference. We try to follow the “single responsibility principle” and give all our methods a specific task. The name “Update” is rather unspecific in comparison to “ManageState”.

The benefit of this approach becomes obvious in larger projects where you have thousands of lines of code which you certainly don’t want to read to be able to understand what the purpose of those lines is. Instead, you would prefer to read a few method names such as “DecreaseHealth” or “MoveToTarget” or something like that. If, for example, there was a problem with the movement of the enemy, you would immediately find the relevant code block just by reading the names of the methods. “DecreaseHealth” does not sound as if it had something to do with the movement, so, given the code is well structured, you could ignore it.

Did this make sense?


See also:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms