L
L
Lynatik0012020-07-15 22:36:05
JavaScript
Lynatik001, 2020-07-15 22:36:05

What is the right way to write code in this situation?

How can you avoid creating variables that perform essentially one action? As for me, the code looks dumb. if, for example, I still have a dozen more "scenes" connections from other files in this file and switching to them again I will have to declare 3-5 variables each time like this.

const BS = new BotScene();
    const Botscene = new Stage([BotScene.mainMenu()]);
    controlPanelScene.use(Botscene.middleware());

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Stalker_RED, 2020-07-15
@Lynatik001

I see two variables, and BS is not used at all, and Botscene is used once, and it can be inlined like this

controlPanelScene.use(new Stage([BotScene.mainMenu()]).middleware());
True, readability suffers, although it is not very good anyway :)
This object is still in memory all the time while it is being used. A variable is just a convenient way to access that object. If you do not need it - you can declare.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question