In CF10 the new
operator calls init implicitly and we need not call it explicitly while creating an object.
But what happens if I have a REST service with an init method; do the properties defined in init become available inside any REST resource?
My tests shows they do not. Ultimately the REST call is invoking a function and I believe that each implicit function invocation results in object creation behind the scenes.
Is REST different than normal object creation/instantiation? Can an init even be created (it can be, but is it a workable/good practice)?
I'm just beginning to look more closely at REST. One thing that I will point out is that REST is stateless. Take a look at the wikipedia description. Each request stands alone, the client should maintain any state that is necessary, and pass that in with the request. The service just responds to requests. I'd say that having an init() in your RESTful service is neither a good nor a bad practice. It might be a handy place to collect function calls and variable settings that you would commonly use during requests. Then when you pass your state in with a request, that method could then call the init(), then go on about its business.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With