Best thing to do is just separate the "super impor...
# general
c
Best thing to do is just separate the "super important" business logic into a non-netsuite module and you can test that all day
s
that's one benefit of NFT. Since it surfaces NS records as POJOs writing unit tests is easy. It's just plain POJOs in the unit tests and NSDAL objects when run in NS (without code changes).
(i.e. no mocking required)
c
but aren't you just testing the framework at that point?
or are you testing the actual business logic
s
no, framework is already tested. we are testing actual business logic only
c
that is pretty appealing then
s
say I have a function that takes a salesorder and does some business logic with it, returning some result.
c
an entire sales order?
s
our unit tests just pass in a POJO representing the SO e.g.
{ sofield1: "hi", sofield2: "there" }
c
Yeah that makes sense
s
without NFT ( NSDAL specifically) you have to resort to funky mocking and such and the tests (and business logic) is far less understandable
c
You've abstracted the "netsuite" side of things into some javascript style
s
exactly
c
Yeah that is how you have to do it whether you use TS or not.. so either way you got it right
its good to hear people are unit testing for sure
s
Yes, NFT/NSDAL was useful long before we started using TS.
For us, TS means a few things - in the most basic sense having type definitions for something like a SalesOrder reduces typos and a few bugs
another thing it helps with is modern JS syntax - arrow functions, spread operators, decorators, consts, classes, etc. Since suitescript tends to be verbose, shorter and clear TS syntax (which is also modern JS for the most part) makes the overall code easier to reason about.
c
Yeah I am not like 100% against TS, I just A) Haven't used it and B) Since A), I don't really see the overall benefit compared to just writing JS.. may just have to try it out and see what it does for me.
I come from a C++/java background so i do like strongly typed languages
s
yeah, I found it interesting that you haven't tried TS given that I know you've done Java as evidenced by the webstorm plugin you had.
TS does have an initial hurdle of newness to overcome, but honestly a lot of 'TypeScript' is just modern, standardized javascript.
and I think you'd be pleasantly surprised at the ES5 output of the TS compiler. It's totally fine to read and reason about, and not unlike what one would write by hand.
I also tried Scala.js (I maintain that Scala is a vastly superior language) but it's JS output was huge and unreadable. Scrapped that for NS development.
c
The plugin was out of a hatred for Eclipse so I broke out java skills but even that has changed so much lately.. I actually applied for a java job after I wrote that plugin and they told me "I didn't know enough java".. i was like what? I've done this for years
Really I just wanna write decent code that gets the job done. I've pretty much relented the idea of trying to make netsuite development fantastic
s
I hear you there!
I just want to make it a bit less painful. I don't do full time NetSuite anymore so it's not so bad.
c
thats fair.. thats all i do is netsuite dev for my "real" job so I try to make it as easy as possible
I'd rather just write 1.0 -> 2.0 and be done w/ it as a business
retire in a few years and move on
s
you may be onto something there. Wonder if anyone has written any tools to help automate 1.0 -> 2.0 SS conversions?
c
Nah thats not really something thats possible because you have no idea how people have written their code and what they need
its best to just go at it from a top down of what do you need, what do you have and here's my suggestion to re-write