Are static inner classes a good idea or poor design?

后端 未结 4 1962
孤独总比滥情好
孤独总比滥情好 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:00

    Note that the class is not the unit of reuse. Therefore, some coupling between classes is normal and expected. The unit of reuse is usually a collection of related classes.

    In Python, we have a variety of structures.

    1. Packages. They contain modules. These are essentially directories with a little bit of Python machinery thrown in.

    2. Modules. They contain classes (and functions). These are files; and can contain any number of closely-related classes. Often, the "inner class" business is handled at this level.

    3. Classes. These can contain inner class definitions as well as method functions. Sometimes (not very often) inner classes may actually be used. This is rare, since the module-level coupling among classes is usually perfectly clear.

提交回复
热议问题