Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

10
  • It’s not a SRP violation, but pretty clearly an Open/Closed Principle violation. That said, I’ve generally found the Ocp to be more trouble than it’s worth Commented Oct 8, 2017 at 5:21
  • 2
    @Paul, Open/Close principle can not be applied for static classes. That was my point, that SRP or OCP principles can not be applied for static classes. You can apply it for static methods. Commented Oct 8, 2017 at 5:53
  • Okay, there was some confusion here. The question's first list of items is not a list of alleged problems. It's a list of common characteristics of the specific methods I'm reviewing. It's context to help answers provide more applicable solutions. I'll edit to clarify. Commented Oct 8, 2017 at 17:08
  • 1
    Re "static class as namespace", the fact it's a common pattern doesn't mean it's not an anti-pattern. The method (which is basically a "free function" to borrow a term from C/C++) within this particular low-cohesion static class is the meaningful entity in this case. In this particular context, it seems structurally better to have a sub-namespace A with 100 single-method static classes (in 100 files) than a static class A with 100 methods in a single file. Commented Oct 8, 2017 at 17:36
  • 1
    I did some fairly major cleanup on your answer, mostly cosmetic. I'm not sure what your last paragraph is about; nobody worries about how they are testing code that calls the Math static class. Commented Oct 10, 2017 at 21:14