What is a good namespace and class name for C#?Why isn't CreateObjectService working?

Asked 2 years ago, Updated 2 years ago, 41 views

I'm a new programmer.

Specify the name of the service that generates an object.

Hoge_Service.web.Services.CreateObjectService

When I named it, my senior told me that I couldn't use the namespace or class name.
What's wrong with you?

I registered the wrong email address when I asked.

c#

2022-09-30 20:17

3 Answers

The .NET Framework contains naming guidelines.Among them,

Do not use underscores to differentiate words, or for that matter, anywhere identifiers.

and Hoge_Service should not be separated by _.

The PascalCasing convention, used for all identifiers exception parameter names, capitalizes the first character of each word

and web should start with capital letters except for parameters.

Name space is

<Company>.(<Product>|<Technology>) [.<Feature>] [.<Subnamespace>]

and Hoge_Service.web.Services does not follow this naming rule.

The class name is

name classes and structures with names or none Phrases, using PascalCasing.

Yes, CreateObjectService is not a noun or noun phrase. CreateObjectService is more appropriate for the method name.


2022-09-30 20:17

Basically, Sayuri is written, but there is one more class name.

What is the name Object for a service that generates an object?

Object should be used (General Naming Conventions

XDO NOTuse Hungarian notation.

XDon't use Hungarian notation.


2022-09-30 20:17

Naoki Fujita is right.My senior knows the answer.However, my relationship has gotten worse and it's hard to hear.

I don't want to improve my linguistic sensibilities.
"From the way my senior spoke at that time, it seemed that there were general rules for naming names and classes, so I asked a question here."I think that's the answer I received from Sayuri and OOPer.

If you follow the answers from the two of you, it will be as follows.

Hoge.Service.Web.Services.SomethingCreationService

If you rewrite it like this, there are words in the namespace that have the same meaning as Service and Services, so I don't think it's a good namespace.I think this is due to the linguistic sensibility Naoki Fujita has mentioned.I think they haven't thought about how to build a namespace.I'll ask my senior if the namespace is good or bad.

Thank you very much Sayuri, OOPer, and Naoki Fujita.

I think I registered the wrong email address when I asked.


2022-09-30 20:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.