I just want to understand the purpose that the static method serves, and what is the desired situation where I can create static methods, except for some that say that static methods are used to create a helper.
I have 1 website that will be used in my company only as a Human Resource Management System , as websites.
Now, after the administrator logs in, the administrator will see a list of employees. So the method is simple, which does nothing more than get all the details of employees from the employee table and displays them on the website, and this method will be in the business access layer, for example, in .net:
public class EmployeeBal { public List<Employee> GetAllEmployees() { return Select * from Employee } }
This is how I would call this method from my application. For Eg (.aspx page or mvc controller, etc.).
var employeeBal= new EmployeeBal(); employeeBal.GetAllEmployees();
So my question is: should I create this method as a static or non-stationary method?
Note. This is just an example of a method, and this method is at my level of access to business .
I have 1 e-commerce site where on the home page I show some list of products, and when visiting this site each user can see this list of products.
so my function will be the same as above in the Business acess layer:
public class ProductBal { public List<Product> DisplayProductonHomePage() { return Select * from Products } }
So my question will be the same as creating this method as a static method or a non-static method, and what happens if more than 10 users can access this website at the same time, what will be the behavior / consequences of this method ???
Will this method serve the purpose of this each user if we declare this method as static?
Can someone answer this question by briefly explaining each scenario ???