What is the recommend naming convention for classes in a multi-tier-application? What is the recommend naming convention for classes in a multi-tier-application? asp.net asp.net

What is the recommend naming convention for classes in a multi-tier-application?


In the MVC paradigm, it's fairly common to have Foo, FooView, and FooController.

You might decide it's easier to stick them in a different hierarchy (Shopping.Model.Cart, Shopping.View.Cart). It's conceptually clean, but I think it's rather unreadable. You can use distinct names in different namespaces instead (Shopping.View.CartView).

A good IDE will let you move/rename things, though, so it's not worth spending too much time worrying over picking the perfect name for something. It's more important to be very clear on what you're modeling and what its limitations are. For example...

  • Is Car an instance of a car or a particular make/model of car? Is a motorcycle a car? If you're going to rename it to Vehicle, is a bicycle a vehicle?
  • Is an Item a type of item, an instance of the item, or quantity instances of the item?
  • Is ShoppingCart just a list of items/quantities, or does it have other features? Does it merge duplicates of an item by summing the quantity?
  • Is a wishlist a special kind of shopping cart (one you haven't bought yet), or something else?
  • Can you "save" a shopping cart and get a quote (so you can print it out, take it to your boss, get it signed off, and then buy it)? Where is the quote stored?


Other StackOverflow folks may know better, but as far as I know, there's no commonly-accepted or industry-standard naming convention relating to tiered architecture. Though I think you're on the right track: moreso than the specific naming, choosing an approach and using it consistently will help make your code more maintainable.


You can use namespace to separate your shopping cart UI and business entity, example:

  • YourApp.Web.UI.ShoppingCart (Your shopping cart web control)
  • YourApp.BusinessEntity.ShoppingCart (Your shopping cart class in your business logic layer)

When you create/use a shopping cart object, it might not be obvious at first look whether the object is a UI control or an entity class, but your IDE (visual studio) will provide you intellisense when you are writing code and a tooltip when you mouseover the name which can ease your problem.

Alternatively, if you really want to ease your eyes for reading, you can use prefix when naming your object:

  • YourApp.Web.UI.ShoppingCart uiShoppingCart;
  • YourApp.BusinessEntity.ShoppingCart beShoppingCart;