Are static inner classes a good idea or poor design?

后端 未结 4 1988
孤独总比滥情好
孤独总比滥情好 2020-12-20 22:38

I\'m find I have several places that having public static inner classes designed that extend \"helper\" classes makes my code a lot more type safe and, in my opinion, readab

4条回答
  •  无人及你
    2020-12-20 23:05

    Sounds perfectly reasonable to me. By making it an inner class, you're making it easy to find and an obvious candidate for review when the searchable class changes.

    Tight coupling is only bad when you couple things that don't really belong together just because one of them happens to call the other one. For classes that collaborate closely, e.g. when, as in your case, one of them exists to support the other, then it's called "cohesion", and it's a good thing.

提交回复
热议问题