^^^ This 1000 times. I suggest this approach for a...
# suitescript
e
^^^ This 1000 times. I suggest this approach for all scripts. Entry points should be nothing more than delegators
s
I agree for logical separation but I don't think logic always needs to be removed to separate files (aka custom module) as I think @creece implies?
c
scripts should be dumb entry points and have no business logic in them. If you extract them out into a library, you have everything separated and your scripts just become some try/catches of exactly whats going on. Whats the use case for not doing this?
s
for me the use case is just simplicity - especially for simple scripts.
c
yeah if its like 1 thing maybe not.. but if its gonna be a big script i'd do it.
s
agreed, I do try to balance the complexity both inside a given script file and across multiple files as needed rather than force a pattern for all scripts. My scripts do tend to be shorter and easier to understand though.
e
It's exceedingly rare I don't have a separate file for the primary logic. The only decisions in my entry point are generally which module(s) to delegate to
but then, separate files and folders have never been something that's bothered me
my brain prefers physical separation
s
fair enough
e
For really small straightforward stuff, @mattdahse has rubbed off on me and I've started making more workflows (depending on client)
s
I'm all for decoupling things, but it's also nice to see all the logic in one file.
I've always found workflows to be a bit clunky - would love to hear why you or Matt pick them over simple scripts?
m
I’m with @stalbert on this. Separate modules for their own sake doesn’t make sense if I’m just adding a button or setting a field.
s
I admit my most common use case for creating a custom module is code reuse
e
We have a whole conversation about workflows vs scripts on Matt's YT channel

https://www.youtube.com/watch?v=DfoiE_0yNVg

👍 1
c
It isn't separating logic just to separate it. You want to make your code clean and easy to maintain and moving things out into modules really helps that. If there's like 1 method or something sure, there's no real reason to break that out. This really applies to larger scale scripts.
PERSONALLY i'd rather open a script and have it well documented and only contain the entry points.. if i need to dive into it, I can just dive into the modules if I need to otherwise what I need is right infront of me
s
Thanks for the link Eric, can't wait to watch a couple NetSuite celebs duke it out 🙂
e
We're always looking for more voices