Static and Instance methods


“Given the internal implementation, you perhaps save a few IL operations if you have static methods. However, having static methods on the BLL/DAL may pose issues at another level.”

Q. What kind of issues we may have by having static methods on BLL?

A. In a nutshell, one won’t run into any issues if the methods are stateless. It’s a debate between whether you want to make your Services and Persistence Layer state aware. If a state has to be maintained then one has to be cognizant of concurrency issues as one would have to synchronize the state maintained by static variables thus degrading the performance of the system. Sometimes, there is a scenario in which one has to use the services as Thread workers and that’s the time one needs to really go with the instance based approach. But, most of the times one can easily go with the static method approach. For example, if you were to look at the code of Application Blocks you would find most of the methods defined are static.


Comments (0)

Skip to main content