hi guys just wondering how you are handling your networking scripts currently im making a visual lobby where players can actually “sit” (think a msn gaming zone type lobby if you’re old enough) but i currently have 3 different structs for serializing data, awake, start, and update, 2 coroutines and 17 methods in one script which all deal with handling creation of the lobbies and communication between server and client but im up to 437lines of code (more then likely 400 due to extra line spacing between methods and sprinkled here and there). to me i can still navigate around in my code base bt my lobbyManager just seems excessive i also needed to make a flow chart to help me more mentally map it out
400 lines isn’t large by any means, generally I try to keep my classes to below 200 but it’s not a hard and fast rule. If the lobbyManager is starting to feel to you unwieldy and taking too much mental dexterity to follow it’s likely a good sign you want to separate out some of its responsibilities.
I’m working on something broadly similar and have managers and services to handle things like games, clients, servers, networking, messaging/processing, lobby, rooms, instances - anything that has a distinct separation of concerns has its own classes. This breaks down the project into more easy to understand components and following clean code principles should make it easier to modify and maintain.
the actual class is not that hard to follow the bulk of the code is in the create lobby and the serializers. the mental dexterity for me is actually from trying to remember what the other classes that im passing data back and forth to.
the smaller methods are basically just bool returns and stuff like that. i also try to stay within the 100/200 line count i guess the more networking i lean i will just need to accept that there’s alot going on at times.