Opinions on CSP methods to REST services?
What are other's thoughts, opinions and experiences going from CSP to RESTful services, specifically when it comes to reusing code in CSP files?
One could define a method in CSP as follows:
<script language="cache" method="SubmitSomethingAwesome" arguments="aswesomeId:%Numeric">
And it's generated in
csp.mycsppage.SubmitSomethingAwesome(awesomeId as %Numeric).
Have people had success defining there rest call by calling the generated CSP classmethod?
Things that work well I've found:
- Procedure block is off so you can easily pass the symbol table around from the REST implementation method to the CSP class method (often there's a lot to be setup before making the call to the class method.
- The obvious pro: you don't have to rewrite code or copy and paste it to a new method.
- Debugging can be simple . . . (see below as well) - since they are methods called from the client, you don't pass in objects, just strings so it's easier to debug in VSCode or command line.
Things that don't work so well:
- You will still have to maintain a CSP page for the life of the REST implementation until you just decide to refactor. That said the <script> tag with the method isn't really any different than a method in a class file.
- Debugging is a bummer - because the procedure block is off it's hard to know which variables you are missing and when something bombs it's hard to track down the error.
I have to imagine this has been discussed on here before but I haven't found it yet. Please link if you know otherwise I look forward to hearing thoughts!