views:

512

answers:

11

Do you write createSomething() or addSomething()?

Do you write readSomething(), getSomething() or fetchSomething()?

This is totally a petty gripe. In the meeting room we refer to it as CRUD, but in actual code, it's becoming AGUD.

What's your naming convention of preference? Does it matter?

thnx.

+2  A: 

I think it depends on the context of the problem/technology - CREATE and ADD can be different.

For example I may CREATE a tag.

And then I may ADD that tag to a page.

We use Repositories to manage our data-access and according to Eric Evans in his Domain Driven Design book you should Add & Remove objects to a repository as if it's an in-memory collection - even if behind the scenes it is using a DB.

But in answer to the original question I still talk about CRUD cos I'm an SQL fanboy at heart! :)

Macka
A: 

I think this is fairly common. Our DAOs certainly are of the Add, Get, Update, Delete (set status to 'C'ancelled, etc) method names. At the DB level they're Inserts, Selects, Updates and Deletes - ISUD.

It could be Persist, Fetch, Delete. Persist either Adding or Updating as necessary.

JeeBee
A: 

Usually, "Get" for the high-level -- get it from wherever: cache, disk, configuration. "Retrieve" gets the value from persistent storage -- normally called by the "Get" if it's not in the cache.

James Curran
A: 

I Create something, and then add it to something else. The add can be part of the create, or sometimes an Update to the containing object.

Darron
A: 

BREAD - browse, read, edit, add, delete.

monzee
+3  A: 

I prefer CRUD over AGUD and AFUD.


CREATE Vs ADD

We are trying to use both of these words to indicate that we are building something new. CREATE leaves no room for interpretation; something that didnt exist before is now being built. ADD can be a little confusing because it could imply that we are adding something that already exists.


READ Vs. GET/FETCH

To me the problem with GET and FETCH here could be interprated as getting a sole instance of an object in order to modify it. I like using READ because it is clear in the sense that I want to read in an instance of an object and that modifying the modifying the object would require a seperate action.

Phil Laliberte
A: 

CRUD works better as an acronym. In practice, I generally use IACREUD:

  • Index lists the elements available for editing; also displays the delete form.
  • Add is the view used to display the form for adding content;
  • Create is the backend code that handles the Add form;
  • Retrieve is the only view used in the frontend application;
  • Edit is the view used to display the form for editing existing content;
  • Update is the backend code that handles the Edit form;
  • Delete is the backend code that handles the Delete form.

I can't really think of a good acronym for that..

Nathan Strong
A: 

I try to use more specific verbs when I can think of appropriate ones (which is pretty hard at 4am). For most things add/edit/delete/get are good enough, and short enough.

Ant P.
A: 

At the end of the day it is up to you as a person and it is what you are happy with in your project. i usually use Get, Add, Search or something similar to that. Regards Mark

markblue777
A: 

it depends on the company's preference and standards. it's not up to me usually, and that is okay with me. a good programmer is flexible.

Devtron
Really, your individual clients look at your code and say "can you make that 'create' to and 'add'...that's just not working for me?"
Typeoneerror
Clients rarely ever look at code, do you have clients that look at naming conventions? At the many programming jobs Ive held, it is generally up to the manager of the project to determine naming conventions. Ive worked with anal managers who do care about this, and Ive worked with companies that do not care (and it shows). I really have no preference and could code it any way the COMPANY prefers. AFterall, it is their code, not mine.
Devtron
I also never said anything about clients looking at code. Where did you dream that up from?
Devtron
Also, let's be clear. I do not build websites for "clients" (or the Backstreet Boys). I write enterprise level software for large businesses. There is a difference.
Devtron
Damn, son. You took that comment way seriously. Chill out.
Typeoneerror
A: 

Do you write createSomething() or addSomething()?

I use createThing() when something doesn't exist, and addThing() if something does exist and we'll be adding a different thing to it.

Do you write readSomething(), getSomething() or fetchSomething()?

I'd use readThing() if I was reading bytes (or similar), getThing() if I'm accessing a property and fetchThing() if I'm accessing an external source.

Depends on context and preference. LSS, Creating something is definitely different from Adding something. Personally, I feel they aren't interchangeable.

Typeoneerror
But does it really matter at the end of the day? Not really. The company still owns the code, and they determine the standards. Unless of course, you run your own operations. I do not, I write code for a living, not for fun, therefore, I am flexible on any project I develop on.
Devtron
I run my own ops, I also write code for fun. Hence my question about whether someone above you generally is concerned over your naming conventions. It's a fair question, I think; and definitely not one that warrents your lame attempt at an insult towards the clientele or "enterprise-level" I work on. A client is a client. I wouldn't turn down work because it's a band I don't like.
Typeoneerror