C# Class naming convention: Is it BaseClass or ClassBase or AbstractClass

前端 未结 8 1120
时光取名叫无心
时光取名叫无心 2020-12-07 14:22

What is the recommended approach to naming base classes? Is it prefixing the type name with \"Base\" or \"Abstract\" or would we just suffi

相关标签:
8条回答
  • 2020-12-07 15:06

    I think its a matter of choice. I'd say if you are creating a lot of base classes then perhaps it is better to go with BaseClassname always because that way you can ALWAYS find out what base classes you can start using by just typing Base and getting the rest of the help from Intellisense. What if you had 20 Base classes and you added Base as suffix and you forgot what was the name of the base class? Do you want to create a class diagram first from VS and find out what base classes are available? It's alright to name them ClassBase when it is just one or two classes.

    Same goes for decision between GetItems and ItemsGet function. I'd say for readability's sake atleast - go for GetItems. Follow the conventions :)

    0 讨论(0)
  • 2020-12-07 15:10

    Personally, I would recommend against adding the word base at all. You never know when you'll have to change the code around and it won't be the base object anymore. That being said, we have done this in the past, we prefixed the word Base on the front. It seems to flow better.

    0 讨论(0)
提交回复
热议问题