0

How do I clean up my global space without having to create +1000 lines .gs files

  • Here follows two photos of some of my files/folders. Mind how low the scroll bar can slide (30+ GAS files) ↓

Files and folders used in my project enter image description here

  • In Apps Script, .gs files cannot be manually mixed like .js modules, which means I cannot import or export (right?), neither control what will be shown when you search for completions;
  • If I wrap it around an interface, I usually end up with +1000 lines of code, which made the whole project difficult to read;
function groupOfFunctions() {
    this.doThis = function() { /* hundreds of lines */ };
    this.doThat = function() { /* hundreds of lines */ };
    // ...
    this.subFunc_N = function() { /* hundreds of lines */ };
    return this; // <-- makes tired face after this
};
  • To avoid that, the project's been organized in a way all Functions rest on the global space;
  • New problem: eventually, my global space has gotten heavily poluted with tons of Functions;

enter image description here enter image description here

  • The scenario is: I usually forget what Functions do, or even that they exist (so many times I coded something that was ready, but lost a
  • I've found no Youtube videos, questions in forums or anything like it anywhere on the internet that talks about how to deal with it, so the question is:

How do I clean up my global space without having to create +1000 lines .gs files

Articles, blogs, videos etc. are welcome.

  • Although I'm not sure whether I could correctly understand your question, for example, using libraries will be included in your expected direction? [Ref](https://developers.google.com/apps-script/guides/libraries) – Tanaike Dec 07 '22 at 00:15
  • Yes, even though last time I tried to do this, I couldn't get any completions (but the functions worked fine). I'm not a Pro coder, so I still rely in completions a lot (I easily get lost, otherwise). I don't know if that's bad. :| – Journiq Educação Dec 07 '22 at 00:23
  • Thank you for replying. I apologize that my comment was not useful for your situation. – Tanaike Dec 07 '22 at 00:55
  • @Tanaike Do you believe a library would be a good idea? – Journiq Educação Dec 07 '22 at 01:10
  • 1
    Thank you for replying. If my understanding of your situation is correct, I thought that using libraries might be useful for being a simple script at the client side. But, in the current stage, jsDoc for the library might not be completely used. So, in this case, for example how about using markdown in the jsDoc? [Ref](https://tanaikech.github.io/2022/07/20/report-documentation-comments-including-jsdoc-for-functions-of-google-apps-script/) By this, it might help the user develop the script at the client side. – Tanaike Dec 07 '22 at 01:14
  • `which made the whole project difficult to read;` You can enable folds in the editor. – TheMaster Dec 07 '22 at 07:46
  • This article helped me a lot! I think this is solved, because JSDoc can generate the completions I need. I created a new Apps Script project, connected it to the library, and organized the lines taking ideas from the article suggests. – Journiq Educação Dec 07 '22 at 07:51
  • Personally, I would avoid libraries for performance reasons – TheMaster Dec 07 '22 at 07:53
  • @TheMaster I understand. Google also advise us to not overuse libraries. So I decided that '3 libraries' would be the maximum, then ended up splitting the main project into 2 libraries. For now, it's working just as before (`console.time` helped me with that), but I didn't test it with a WebApp yet. – Journiq Educação Dec 09 '22 at 00:23

0 Answers0