https://netsuiteprofessionals.com logo
#general
Title
# general
c

creece

03/22/2018, 7:35 PM
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

stalbert

03/22/2018, 7:44 PM
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

creece

03/22/2018, 7:45 PM
but aren't you just testing the framework at that point?
or are you testing the actual business logic
s

stalbert

03/22/2018, 7:46 PM
no, framework is already tested. we are testing actual business logic only
c

creece

03/22/2018, 7:46 PM
that is pretty appealing then
s

stalbert

03/22/2018, 7:46 PM
say I have a function that takes a salesorder and does some business logic with it, returning some result.
c

creece

03/22/2018, 7:47 PM
an entire sales order?
s

stalbert

03/22/2018, 7:47 PM
our unit tests just pass in a POJO representing the SO e.g.
{ sofield1: "hi", sofield2: "there" }
c

creece

03/22/2018, 7:50 PM
Yeah that makes sense
s

stalbert

03/22/2018, 7:50 PM
without NFT ( NSDAL specifically) you have to resort to funky mocking and such and the tests (and business logic) is far less understandable
c

creece

03/22/2018, 7:50 PM
You've abstracted the "netsuite" side of things into some javascript style
s

stalbert

03/22/2018, 7:50 PM
exactly
c

creece

03/22/2018, 7:50 PM
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

stalbert

03/22/2018, 7:51 PM
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

creece

03/22/2018, 8:00 PM
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

stalbert

03/22/2018, 8:08 PM
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

creece

03/22/2018, 8:14 PM
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

stalbert

03/22/2018, 8:34 PM
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

creece

03/22/2018, 8:37 PM
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

stalbert

03/22/2018, 8:40 PM
you may be onto something there. Wonder if anyone has written any tools to help automate 1.0 -> 2.0 SS conversions?
c

creece

03/22/2018, 8:41 PM
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