Класс должен иметь то же имя как пространство имен?

Осуществленные представления являются находящимися на диске и периодически обновляются основанные на определении запроса.

Представления являются виртуальными только и выполняют определение запроса каждый раз, когда к ним получают доступ.

5
задан skaffman 26 November 2009 в 13:48
поделиться

4 ответа

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.
1
ответ дан 15 December 2019 в 01:03
поделиться

The namespace is Fusion.User
Class Full Name would be Fusion.User.User

It is a good practise to keep them different because

  1. It avoids confusion to the developer
  2. It also looks ugly in some cases like here we are using two user.

    using Fusion;
    namespace xyz {
    public class test
    {
    User.User userObject {get;set;}
    }
    }
    Поэтому лучшим вариантом было бы использовать разные имена

1
ответ дан 15 December 2019 в 01:03
поделиться

There are instances where using the same name will cause problems. One that leaps immediately to mind is when consuming a WCF service. When I did this recently in a class called "someBehaviour" in the namespace "companyName.someBehaviour" to consume "MyService", the compiler barfed on me saying that MyService didn't exist within the someBehaviour namespace. Changing the class name to something different (and vastly more useful) solved the issue and allowed me to compile the assembly.

1
ответ дан 15 December 2019 в 01:03
поделиться

Я бы, наверное, назвал пространство имен «пользовательскими задачами», чтобы избежать путаницы. Вам нужно будет регулярно квалифицировать внутренний класс, используя пространство имен, чтобы не запутать компилятор.

0
ответ дан 15 December 2019 в 01:03
поделиться
Другие вопросы по тегам:

Похожие вопросы: