Skip to main content

Naming Conventions

The following naming convention must be followed when creating any of the MVC pattern sections. All names must be created using Pascal-Case.

Model

  • The name is always a singularized representation of the database entity e.g. for the data base entity prsEmployees it must be prsEmployee
  •  When a model is required that is made up of SQL procedures for a specific domain of data, the name must represent the domain of data e.g. BadgesAndPoints is a model of different SQL objects returning data regarding badges and/ or points and nothing else.

Controller

  • Every controller must be suffixed with the word Controller e.g HomeController
  • Every controller must be placed within the ~/Controllers folder of its area

Attributes

All custom filter attributes must be named according to its function e.g. BypassSessionAuthorisation

View

  • The view's name must represent the type of data it displays e.g. CreateEdit.cshtml
  • The partialview's name must represent the type of data it displays and must always start with a underscore e.g. _OrderDetail.cshtml
  • Every view must be placed within the ~/Views folder of its area matching the controllers name

e.g. for the HomeController

image-1602128806399.png

  • When the view is used by multiple controller it must be placed within the ~/Views/Shared folder of that area

View Models

  • The name must always end with the postfix ViewModel
  • The name can start with the action it is called from e.g. LoginViewModel 
  • The name can start with a descriptive name defining the type of data it encapsulates e.g. EmployeeDetailViewModel

Routing 

The registrations file for a areas route must be named {AreaName}AreaRegistration e.g LearningStoreRegistration.cs