Does anyone have an idea how to implement MVC for ...
# suitecommerce
v
Does anyone have an idea how to implement MVC for SS2.0 based SC extensions? Do I write all my backend code in the SS2.0 Service.ss file or is there a way/requirement to implement a ServiceController and backend Model for 2.0 scripts as well?
s
The MVC paradigm hasn't changed since we introduced support for SS 2.0 in extensions. What has changed, though, is that it is not currently possible to require/import core SCA SS 2.0 modules into extensions. With SS 1.0, we typically say "use the auto-generated services", which means using the ServiceController module. As it stands, it's not possible to include that directly from the core code, so there's no direct path for you to migrate a "full" SS1.0 module over to SS2.0 without doing a bunch of manual work yourself.
So what we are saying is, SS 2.0 is supported and you should use it if you can. It has a lot of stuff that will work in simple situations, but for more complex scenarios, you may find it particularly difficult because there is no clear map.
In addition to core SCA modules not being accessible, you can't also access the configuration record easily, for example. There are a bunch of SCA-specific things, not really feasible in SS 2.0 extensions, so if you can't convert, don't.
v
That paints a very clear picture for me, Steve. Thanks for the detailed, straightforward answer. I understand that it is best to avoid migration when our SS 1.0 based extensions are interacting with core SCA modules/Commerce API/Configuration module. But what about when we're writing a service from scratch? Is it okay to write all our code in the SS2.0 Service.ss? (this is, of course, when we are implementing simple SuiteScript based solutions that don't interact with any SC/SCA modules)
s
SS 2.0 is modular, using the same define/require pattern you'll be familiar with from working with SC already. There's no reason why you couldn't break things up in other modules and files and keep them all separate.
v
Got it. That was my primary concern as to how can one implement a ServiceController and a backend SC Model for 2.0 services. But as you said, since SS2.0 is already modular, I guess we can just build a modular solution like we're used to making outside of SC.