How to develop project with thousand rows of code

I need to any suggestion, how to develop a project with thousand rows.
Create many files and edit code from console or a any IDE.

My project use this technique:

Load core object as global param

const _Notify = class Notify{

    constructor(){
        
    }

    send_msg_TG(){

    }
}

const engine = class Engine {
    Notify = _Notify
    Balances = _Balances
    Storages = _Storages
    DB_SQL = _DB_SQL

    constructor(){

    }
}

global.set('engine', engine)

Use object in any node( function )

let engine = global.get('engine')
let obj_engine = new engine()
let nt = new obj_engine.Notify()
nt.send_msg_TG()

Main code hard to maintain and develope in embeded browser editor.
Thank to any thoughts!

Hi @Alexander_xD welcome to the forum.

Your approach is a similar one that many experienced programmers take when they first start using a low-code and FBP (flow based programming) platform. They try to apply the disciplines they know from regular application programming. To be blunt, this is not the best nor the optimum approach with a FBP system.

The advantages of the Node-RED platform are that you can visually (and at runtime) fix, update or add to small parts of your application without thousands of lines of "boilerplate" code. A bit like "On-line modification of a PLC" where you can fix issues during production.

Many parts of your current code will be "pluming" (e.g. setup class instances, adding event listeners, adding boilerplate express setup and routes, boilerplate database connections setup, etc) all of which become simple "nodes" and thus reduce your code almost to "just the logic", represented visually.

Approach

Ideally, you use core built-in nodes (and where necessary, a hand full of contrib nodes) and you wire these together to form the logic of your application. This gives you a visual representation of your program.

If you continue down a traditional programmers path (creating code classes, instantiating them, writing all your own routes and database initialisation etc), you will lose the runtime modification benefits, the "at a glance" visual benefits and will ultimately be more difficult to maintain - at which point I would probably ask "why are you using node-red"?

I understand this may seem daunting and seem alien at first however I hope you take this on board by someone who started out like you (using function nodes "because I knew how to program") and accept there is a better way.

My 2¢

1 Like