Search Unity

Are "noun Monobehaviours" discouraged in a GameObject/MonoBehaviour architecture?

Discussion in 'Scripting' started by IgnisIncendio, Dec 24, 2018.

  1. IgnisIncendio

    IgnisIncendio

    Joined:
    Aug 16, 2017
    Posts:
    223
    I've heard that monobehaviours like "Player" or "Bomb" are discouraged, and that I should break them up into more generic scripts such as Movement/Shooting or Timer/Explosion/ExplosionOnTimerFinish/TimerBeep etc.

    Is this true? Or am I being too dogmatic here?
     
  2. Depending on the demand for performance the separation of concerns usually a good idea.
     
  3. IgnisIncendio

    IgnisIncendio

    Joined:
    Aug 16, 2017
    Posts:
    223
    Performance isn't really a big issue for the games I'm working with. What about for clean code? Thanks for replying btw.
     
  4. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    Haven't heard of that. If you're working in a team, and it's prohibited somewhat, then don't name them like that.
    Otherwise, do whatever.

    Code being clean and nice doesn't depend on how you name classes. It depends on how you write your logic.

    E.g. I can easily make a decent decoupled and clean "Bomb", as well as "Explosion". So naming means about nothing.
    Actually, I would prefer neither of that. But it really depends on the context of the game you're making.
     
    IgnisIncendio likes this.