Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Discussion Which code convention is better in your opinion?

Discussion in 'Multiplayer' started by mishakozlov74, May 10, 2024.

?

What would you like better?

  1. One file

    0 vote(s)
    0.0%
  2. Multiple files

    100.0%
  1. mishakozlov74

    mishakozlov74

    Joined:
    Aug 8, 2018
    Posts:
    144
    Hello, me and my college are working on a Facepunch transport for one of networking solutions for Unity. Lately we had a discussion about the way we should structure our code. It's public, so UX is our essential priority, therefore we'd like to hear other opinions.

    There are three classes we have:
    1. FacepunchTransportProvider - description of ScriptableObject that stores configuration for the transport and has a method to create it based on that config.
    2. FacepunchConnection - Internal connection class that stores information about connected client
    3. FacepunchTransport - Transport itself, that implements few interfaces and does everything important.

    So there are two options:
    1. Combine all three classes in one file. Since it's going to store definition for a ScriptableObject, it must go by the name FacepunchTransportProvider
    2. Store every class in a separated file, following class-per-file convention.

    Thanks.