However, i don't see any justification to make an entire class static Its behavior can be passed around like the value of a variable Why and when should i make a class static
Leaked Instagram
What benefits do i get from making a class static?
Just want to add that it's 2024 and we've had static interfaces for a while now
They also solve the problem of static classes are evil because thanks to static interfaces you can have multiple implementation classes, mocks, etc Just like you can with regular classes. If you're going to use dependencies in your methods you should give them an instance If you want to have helper methods that do complicated stuff, then use a proper helper class, and accept the inavigator as an argument
Class navigatorhelper { protected readonly ilogger _logger } a few of my team members suggested that we declare the class as sealed to avoid overriding option, and a few are suggesting that we mark it as static to avoid instance creation of the constant class I am very curious as to thoughts and industry best practices regarding static members, or entire static classes This is how it's now i have a static class that gets and parses the json, then stores it in an object and all objects are then stored in an object list
This class has 2 public methods, 1 private method and about 200 lines of code
I then have a static class that loops through the object list and calculates the results based on each objects values. Which is why it would be an ordinary class instead of a static one, because the ordinary class can hold state variables containing the service layer dependencies. A method in another class (where the state matters). The static method is unit testable, but what about the methods that call the static method
If the callers are in another class then they have a dependency that needs to be decoupled to do a unit test. Static methods aren't first class in oop languages By giving the method an object to live in, even one with no state, we make the method portable