I currently have a class MyClass
with a constructor that logs into a Web Service, returns a Session ID if it doesn't already have one, and saves it in a private static SomeWebService service
attribute.
In my controller, a call would look like new MyClass().doSomething()
which in turn would end up calling service.someWebServiceMethod()
within MyClass
.
Is it appropriate to continue creating a new MyClass
for every call, seeing as I'm saving the session itself as static
? Would it be more ideal to make SomeWebService service
non-static and implement the Singleton pattern instead? Does it even matter?
I saw this thread as I was about to switch to Singleton and now I'm unsure which approach to take.