Folks,
We have an exception handler class that I am adding code to provide email notification. My question is when I'm in the body of the exception handler should I call the EmailNotification by passing the exception and Class context to a static method or do I need to instantiate a new EmailNotification type class, then call a notify type method.
To make things plain, is there anything wrong with calling a static method in another class? Or is it for some reason better to instantiate a new object of that class then invoke the desired method.
It would seem to me that the static method would be less weight but is there something I'm missing, any concurrency issues?
Please advise, thanks!
-
Use static method or instantiate a class (2 messages)
- Posted by: Marko Rocko
- Posted on: April 26 2006 12:37 EDT
Threaded Messages (2)
- Use static method or instantiate a class by Emil Kirschner on April 27 2006 10:07 EDT
- Use static method or instantiate a class by Marko Rocko on April 27 2006 12:14 EDT
-
Use static method or instantiate a class[ Go to top ]
- Posted by: Emil Kirschner
- Posted on: April 27 2006 10:07 EDT
- in response to Marko Rocko
To make things plain, is there anything wrong with calling a static method in another class? Or is it for some reason better to instantiate a new object of that class then invoke the desired method.It would seem to me that the static method would be less weight but is there something I'm missing, any concurrency issues?Please advise, thanks!
creatign a new instance would only create a new object to be garbaged later. If your static methos is stateless - I don't see why a methods that sends mail wouldn't be - then there are no concurency issues.
hope it helps,
Emil ( http://www.thekirschners.com/software/testare/testare.html ) -
Use static method or instantiate a class[ Go to top ]
- Posted by: Marko Rocko
- Posted on: April 27 2006 12:14 EDT
- in response to Emil Kirschner
Gracias.