开发者

How do you Name and Organize CLASS Files?

I use ASP.NE开发者_运维技巧T in C#, I am pretty new at developing so I would like have some advice from experts :-).

Questions:

  • What is the best practice to organizing CLASS FILES?
  • What kind of name do you use?
  • For Web Application Project, how do you name NAMESPACE?

In my Case I am building a simple CMS. I thought the FILE structure like this:

- AppCode
  - Common
    - UserDataInput.cs
  - ExternalLibrary
  - BusinessLayer
    - FrontEnd
    - BackEnd
  - AccessLayer

Thanks guys for sharing your thoughts with me! Bye


Naming conventions are different for everyone there are no right answers only best practices but there are plenty of wrong ones. When it comes to object oriented programming don't overkill for the sake of modularity some things, like a DataHelpers project which would be be used in your backend could be something you carry around but, say a gravatar helper class (which is an actual class under Microsoft.Web.Helpers) is an overkill simply because String.Format() and a md5 hashing method is all you need for that. It's pretty much eyeballing what you would need again in another project when it comes to modularity.

This goes without saying but, make sure what you name your methods classes make sense in the context that you work, when working with asp.net MVC what I would have a CMS.Controller project and a CMS.View project but all will be under the CMS solution where in classic ASP.net I would have named CMS.BL or CMS.Web. I wouldn't place anything under AppCode just add projects to your solutions and don't call them Common, when carrying your code across solutions they become overcrowded with *.Common namespaces.

So classify your code trough projects in terms of what they are used for and be sure to implement a hierarchy so that your classX that inherits from Xbase is under same sort of hierarchy in temrs of project when you implement this kind of a pattern in your projects you will be more sucsessfull as opposed to Xbase being under CSM.Web.Core and classX under CMS.Web which will later on pave the road to circular references.

Here is an example of a project im working on, it started as a MVC application but later turned into a prject that has winforms and everything.

As long as stuff make sense to you and you are comfortable with, you can get away with everything, like there in the solution below i have a Data.Netsis.Entities that inherits from Entities.Netsis.

How do you Name and Organize CLASS Files?

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜