Extension objects usage during calls

Extension objects usage during calls

  
Hi there.

I'm having some trouble making sense of how outsystems handles it's extension objects.
Does outsystems instantiate as many classes as it needs on the lowest scope possible, or does it share instances between calls? For example, If i use an extension X with an action A in a web screen's action, will the same X be used in different calls by the same client? What about with different clients?

And what if I call the extension on a web service action? Is there any chance that the same instance will be shared by different web service actions?
Hi Ricardo,

By classes you mean the extension main class where you write the actions?
I'm pretty sure that it is a singleton in most cases, but you sould not assume it. I would recommend you to avoid declaring any local variables at the class level unless they are static and threadsafe (to keep global caches for example).

What are you trying to achieve? You want reuse or not?

Regards,
João Rosado




What are you actu
Hello João.

Yes, i'm talking about the main class.
I was asking because I was indeed trying to declare a class variable to simplify it's usage in my code. If outystems follows a singleton pattern for extention instatiating then i'll have to declare locally in a method, but i guess i'll test sometime later how it would work with concurrency as a class variable.
Solution
Hi,

Personally, what I usually do on my extensions when I need to share complex logic between multiple actions is to create another class to hold all the complex logic.
Then on the actions in the main extension class just instanciate my helper class once and call the necessary action from it. That way you are the one that are controlling who/when the classes are created without having to know how the platform works internally.

Regards,
João Rosado
Solution