Should a class have the same name as the namespace?

前端 未结 5 1586
陌清茗
陌清茗 2021-01-19 01:27

I\'m designing a namespace to hold a set of classes that will handle user related tasks for a several different applications. (Log-in, authenticate etc)

5条回答
  •  萌比男神i
    2021-01-19 01:39

    Having class named in the same way as the name space (package) may lead to a thought that class is central to the package. But if I get it correctly User is just a data object in your case.

    As far as I see you have 2 options:

    1. Name your name space differently e.g. Fusion.Security
    2. Use suffix for class name indicating its purpose e.g. UserDTO, UserAction etc.

提交回复
热议问题