Search Unity

Question about Project Directory Structure and Class Naming Convention

Discussion in 'Open Projects' started by Shukerullah, Jul 5, 2021.

  1. Shukerullah

    Shukerullah

    Joined:
    Mar 15, 2013
    Posts:
    97
    Hello Unity Peeps!

    First, thank you so much for making this interesting project. It's a great opportunity for us to learn from it. I have few questions that are very importing for me, I am bit organized when it comes to organizing directories and naming a variable.

    Folder Structure
    We have EventChannels and Events folders inside ScriptableObjects. Both folders have scriptable object (EventChannels->OnGameExit and Events->Camera->CameraShakeEvent), these objects have same script (VoidEventChannelSO). Then why we have EventChannels folder when their scriptable object can have same script as Events, can't we create Channels as sub-folder of Events?

    Class
    Why we use Prefix for UI scripts (UIPopup) and suffix for scriptable objects (VoidEventChannelSO)?
     
    cirocontinisio likes this.
  2. cirocontinisio

    cirocontinisio

    Joined:
    Jun 20, 2016
    Posts:
    884
    Yes, and they should be there, but since we're in a constant state of work-in-progress with many open PRs, we never relocated those events. Once things are a bit more quiet on the PR side I might make a bit of a cleanup.

    You mean why one is a prefix and the other is a suffix? Because they are positioned like they'd do in English, if the name was "expanded":
    - a User Interface Popup
    - a Void Event Channel Scriptable Object
     
    ChemaDmk likes this.
  3. Shukerullah

    Shukerullah

    Joined:
    Mar 15, 2013
    Posts:
    97
    This make sense. Thank you so much for the clarification.
     
    cirocontinisio likes this.
  4. IsaiahKelly

    IsaiahKelly

    Joined:
    Nov 11, 2012
    Posts:
    418
    Personally, I hate the use of "SO" as a suffix for all ScriptableObject classes. I understand it is used here to distinguish them from MonoBehaviours, but that is very often completely unnecessary or there are just much better ways to do so. For example, there is no reason to add "SO" to the end of an EventChannel script. If you must separate or group them, then you could much more easily do that with just a namespace instead.

    Other times, when there is a pair of scripts (MonoBehaviour + ScriptableObject) "SO" is just added to the end of one. Which feels really lazy and also doesn't make their actual differences clear at all, which combined with the unfamiliar acronym, is very likely to confuse newcomers. So I would at least go with "Data" or "Asset" as a default suffix instead, at the very least.

    @cirocontinisio Speaking of namespaces, this is something of a mess. Many classes do not have any, while others are using "UOP1" which seems outdated. So do you plan to add/change this namespace to "ChopChop" eventually? If so, I could start by using that in my own feature.
     
    Shukerullah likes this.