[ACCEPTED]-Action Naming Convention-model-view-controller
Rob Conery at MS suggested some useful RESTful 2 style naming for actions.
* Index - the main "landing" page. This is also the default endpoint. * List - a list of whatever "thing" you're showing them - like a list of Products. * Show - a particular item of whatever "thing" you're showing them (like a Product) * Edit - an edit page for the "thing" * New - a create page for the "thing" * Create - creates a new "thing" (and saves it if you're using a DB) * Update - updates the "thing" * Delete - deletes the "thing"
results in URLs 1 along the lines of (for a forum)
* http://mysite/forum/group/list - shows all the groups in my forum * http://mysite/forum/forums/show/1 - shows all the topics in forum id=1 * http://mysite/forums/topic/show/20 - shows all the posts for topic id=20
Rails has a nice action naming convention 1 for CRUD operations: Rails Routing from the Outside In.
HTTP Verb Path Controller#Action Used for
GET /photos photos#index display a list of all photos
GET /photos/new photos#new return an HTML form for creating a new photo
POST /photos photos#create create a new photo
GET /photos/:id photos#show display a specific photo
GET /photos/:id/edit photos#edit return an HTML form for editing a photo
PATCH/PUT /photos/:id photos#update update a specific photo
DELETE /photos/:id photos#destroy delete a specific photo
This is essentially an update to Paul Shannon's answer, since his source (Rob Conery) implicitly says that he copied his list from Rails.
I've found a blog post by Stephen Walther useful for finding a consistent 3 naming scheme. His are also derived from 2 a REST-style naming scheme, with some unique 1 exceptions that he explains.
Stephen Walther's post on ASP.NET MVC Tip #11 – Use Standard Controller Action Names would probably 2 clarify you regarding to naming convention 1 of MVC Action
naming convention...
The builtin Django actions suffix _done. So 2 LoginDone would be the page that processes 1 Login (in ASP.NET MVC camel case style).
It's fairly irrelevant which convention 16 you use for the Controller Action naming, as 15 long as it's consistant for you and easily 14 understood by those working on it.
In the 13 case of your login Actions, LoginDone is 12 fine and in the same was ProcessLogin will 11 is easy to understand, so use a convention 10 that you feel comfortable with.
Personally 9 I would probably side with Login and ProcessLogin, as 8 LoginDone is probably slightly misleading 7 in terms of what the Action is doing - this 6 is of course assuming that the Action is 5 reacting to the users' credentials and checking 4 whether they are valid. You could then pass 3 through to another Action called LoginDone 2 once the login is successful, or LoginFailed 1 if it's not.
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.