Bad practice to have two classes of the same name in different packages?

前端 未结 5 1580
Happy的楠姐
Happy的楠姐 2021-01-17 13:41

We have split our application so that package A handles data from one external source and package B from another. In both cases we need to create a domain object and have a

5条回答
  •  不要未来只要你来
    2021-01-17 14:10

    Not really poor practice, as in many domains have similar terminology, so you will end-up having same names. On the other hand if both are in same domain, but simply different implementations, you can (somehow) indicate the implementation specifics in the name.
    The very ugly thing would be if you have to use both in same source file, in this case you have to use fully qualified name for at least one.

    Examples:

    java.util.List java.awt.List

    indicate implementation in the name:
    java.util.ArrayList
    java.util.LinkedList

提交回复
热议问题