Private nested static class - Good or bad practice?

后端 未结 6 557
[愿得一人]
[愿得一人] 2021-01-04 03:20

Would it be considered a bad practice to nest a private static class inside of a non-static class?

public class Outer
{
    private static class Inner
    {
         


        
6条回答
  •  囚心锁ツ
    2021-01-04 04:07

    Nothing wrong with it in principle, though if you're wanting a nested static class to help organize static state or methods, it could be a warning sign that the class is growing too large. Nested private classes have a lot of uses (internal data structures, private implementations of passed out private interfaces, etc.), but a static private class is really just a way to group things together.

提交回复
热议问题