Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Examples of documentation models for scripts

Discussion in 'General Discussion' started by Pytchoun, Apr 18, 2022.

  1. Pytchoun

    Pytchoun

    Joined:
    Apr 12, 2015
    Posts:
    203
    Hello,

    Do you have examples of documentation models to explain the different scripts that make up the project in order to find your way around?
     
  2. Pytchoun

    Pytchoun

    Joined:
    Apr 12, 2015
    Posts:
    203
    Hello,

    When we have hundreds of scripts and we work in groups it is difficult to know what each script does.

    How do you document?
     
  3. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,528
    Hi,

    First, use SOLID principles and organize groups of scripts into assembly definitions to enforce decoupling of modules that perform different functions.

    Then use standard C# XML tags in your comments. Your code editor will probably set up templates if you move your cursor to the beginning of some code such as a method and type "///". These XML tags serve two purposes:
    1. Your code editor will usually show them as a tooltip when it's presenting autocomplete information as you type code, and
    2. You can run a tool such as Doxygen on your code to generate an API reference in HTML. You can then put this HTML on your team's website for all of your teammates to reference.
     
    angrypenguin and BIGTIMEMASTER like this.
  4. nijnstein

    nijnstein

    Joined:
    Feb 6, 2021
    Posts:
    78
    The organization of the scripts into a decent structure will save a lot on documentation as many things simply not need to be known to the user of those scripts.
    Hundreds of scripts aint very much to keep structured and it sounds to me that if anyone needs to know what every script does then youre scripts have a lot of side effects that need to be known about. SOLID aplies but also critical thinking about how to name things. If you cannot describe what something does in its class/filename then probably its doing too much.
     
    angrypenguin likes this.
  5. BIGTIMEMASTER

    BIGTIMEMASTER

    Joined:
    Jun 1, 2017
    Posts:
    5,181
    thanks, this helped answer some questions i've had recently.
     
    TonyLi likes this.
  6. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,509
    I loudly echo the idea that good organisation drastically cuts down on documentation needs, and other overheads too.

    As for the comments themselves, focus on what we can't read from the code. What is its purpose? Why is it implemented this way? Any gotchas (easy mistakes to make) when using or changing it? External factors influencing its design?
     
    TonyLi likes this.
  7. SamTheLearned

    SamTheLearned

    Joined:
    Jun 23, 2021
    Posts:
    84
    1. A single folder for scripts is fine for prototypes and small games but I think the larger a project is the more reason to divide scripts by feature type in folder organization. Its easier to find the feature then dive into its scripts than have them all jumbled into one place scrolling through all the names. This also brings a slew of other improvements such as ease of upgrading or switching out features.

    2. Get better at naming classes. I honestly get a dopamine rush coming up with a good descriptive name of what something is. Its a skill in and of itself. So improve on defining what something is and what something does. if working in a team make sure all team member agree on naming conventions as well.

    3. The better you name things, the more powerful search becomes. Start using search at this point with hundreds of scripts. This will pair well with naming conventions.
     
  8. kdgalla

    kdgalla

    Joined:
    Mar 15, 2013
    Posts:
    4,354
    Yeah, there is a concept in software development called "self-documenting code" or "self-describing code", Choose names that describe what your code does and what it's meant to be used for. Come-up with a good naming convention and stick to it.