Interests from the point of view of optimization. Rummaged on the official unit, but there things are more serious offer to optimize

  • IMHO 1 is long. But the profiler will say more precisely. - pavel
  • And what does one script mean, but “long”, or several “small” ones? If you mean that you have in one script both control and physics and interaction with enemies and scoring, etc. - this is of course wrong .. it’s necessary to separate. If you have a script, for example, a character controller and it just cannot by itself to be small - let him be. One file should reflect the essence of its name in fact and nothing superfluous and there is no point in sharing. Usually they make some abstract classes with the basic implementation, interfaces, etc. And in the main scripts they are inherited from them. As a result, a lot of things are being saved. - Alexey Shimansky
  • Yes, in general, the concept of a long / small blurry ..... Someone thinks 200 lines are already a giant, and someone even 5000 normal - Alexey Shimansky
  • Mm, for example, a "long" script - an object in it is created and destroyed. And two “little ones” are created in one and destroyed in the other. And I am interested in which option works faster. We do not take into account the "clarity" of the name - here you can clearly call it, and so on. But which is more optimal in terms of speed? It seems like a multi-functional should work better, but who knows ... - Krem Soda

1 answer 1

A few years ago I was working on accounting systems, working in particular with Microsoft Dynamics AX. There was a set of Best Practics rules that every self-respecting programmer tried to follow. There, of course, work with objects looks somewhat different, its own specifics, but the rules are good. If the method does not fit on one page, then the method should be split. Each object, and in it the method must perform an atomic task, and the meaning of the action must be clear from the name. If you feel that your component is overloaded and in addition to following the person running, it also writes replicas in quests and writes data to the server, then something is obviously wrong with the solution architecture.

For all I will not say, but I try to do so. I have a task to get control from the user, there is a task to move the character. I make my own component for each task. It will be necessary then to immobilize the character, I will turn off the component with control from the player and voila. We take the task and decide how complicated it is, and then divide it at our discretion. The main thing is not to overdo it.