Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(Conventions) C# Class names

I'm not too quite sure about what i should do about a grouped set of classes.

My situation: I have 11 classes that relate only to the class Character.cs, but all of those classes (including Character.cs and CharacterManager.cs) are within the namespace Models.Characters.

Which is the more "proper" or preferred way of naming the classes:

(examples):

CharacterDetails.cs CharacterSprites CharacterAppearance CharacterClientRights CharacterServerRights

or:

Details.cs Sprites Appearance ClientRights ServerRights

(They're all noticed in Models.Characters (so eg. Models.Characters.CharacterDetails, Models.Characters.Appearance)

Thanks in advance.

like image 865
TheAJ Avatar asked Nov 29 '22 19:11

TheAJ


1 Answers

Personally for me it"depends". Usually I would prefix everything with the word Character to keep things consistant, however if you have everything already under the Character namespace the Character prefix could seem redundant.

I could easily see going with the shorter convention of Models.Character.[X] if there never will be another class called Details, if there for instance could be UserDetails then Details and UserDetails could be confusing when looking back at the code weeks or months from now and I would personally prefer then the CharacterDetails option.

In the end it is your personal preference, what more accurately describes your domain, Details or CharacterDetails?

like image 156
Mark Coleman Avatar answered Dec 06 '22 06:12

Mark Coleman