Add functions in custom <module>.php - upgade safe

Hello, dear Sugar Community,

I built a custom module via Module Builder and I would like to add functions in the <module>.php file in an upgrade safe way.  So, I have to do it via the path of  "/custom/....", but In which paths do I have to add my files and what files should I extend?

 I use version 8 of SugarCRM.

Any help is really appreciated!