41

I'd like to know if someone has a better word than authored or produced, for both creating and updating something.

Context: I'm a software developer and I'm trying to think of a clever way to name the function that will initially create an object, and if it's already created, update it.

  • 3
    Crupdate? Someone had the same problem with you and neologized crupdate also :) – ermanen Feb 17 '15 at 2:42
  • 20
    The standard terminology in the RDBMS world is "upsert". – Dan Bron Feb 17 '15 at 2:55
  • 1
    Is it weird that I find these really funny? Thanks for the suggestions! – undefined Feb 17 '15 at 2:58
  • This question is better asked on a relevant tech Q&A or SO. – Kris Feb 17 '15 at 6:45
  • 1
    Exactly the question I had in mind. I went into the thesaurus after looking at the answers, and came up with these: manage, commit, save, renew, refresh, maintain, secure, store, support, install, keep, store, stash, ... I think I like save, because in the context of computers (operating systems, actually), saving a file means both creating one if it doesn't exists, and updating it if it already exists. – ADTC Mar 12 '16 at 12:59
34

"Save" seems perfect for this. As a developer I'd read "SaveRecord" as either inserting or updating the record depending on its preexistence.

  • I like it! In the context of computers (operating systems, actually), saving a file means both creating one if it doesn't exists, and updating it if it already exists. A programmer is also a user, so it's very relatable (indeed, we save our source code, don't we?). – ADTC Mar 12 '16 at 13:03
10

Since you stated you're dealing with JavaScript, I'll offer 'assign' as a handy verb. In most programming languages, you need to declare an object property before assigning it, but in JavaScript the assignment operator ('=') both updates and creates properties (when they don't exist).

So if you have your generic object here, and you want to create/update properties of that object using a single function call, you're essentially assigning values to the properties of the object. Creation is implied.

 myObject.prototype.assignProperties = (property, value) => this.property = value;

The only activity carried out in the function is 'assign' by the assignment operator. If the property doesn't exist, it is created.

Source: I'm a software engineer working with JavaScript regularly (FireFox OS applications).

  • 1
    Thanks! Another really nice solution though I still prefer set because it's much shorter, and abbreviating assign would give me, well..ass – undefined Feb 17 '15 at 2:55
  • 1
    I work in Tokyo, so 'assData', 'assProps', 'assTime', etc. would be happily unnoticed ;) A wonderful idea for when morale dips. – Coty Johnathan Saxman Feb 17 '15 at 3:01
6

Sometimes set is used in programming to refer to both creating and updating. It can depend on the language - some languages clearly separate the two operations, some do not.

Some languages try to be clear by not using a single verb for this. For example, SQL uses the verb CREATE OR REPLACE to mean exactly what it says (and what you said).

My suggestion is to check with your language and its users, to see what vocabulary is typically used for this in the particular context.

  • 1
    Thanks! set is a really good option, I'm working with JavaScript, I'll see if anyone else comes up with something different :) – undefined Feb 17 '15 at 2:16
  • 1
    Just make sure that you can create a JavaScript object using the same operation as you use to update it. If not, then talking about setting it is not so appropriate. Typically, with OOP languages (such as JavaScript), the creation of an instance is done one way (e.g. with a constructor), and updating is done another way (e.g. with a setter function). – Drew Feb 17 '15 at 2:18
  • @Drew JavaScript is very forgiving when it comes to things like that. You can certainly make 'classes' and instantiate objects and implement constructors, but at times when it suits you to build-as-you-go, creating and setting with the same function is actually quite natural. – Coty Johnathan Saxman Feb 17 '15 at 2:56
  • @CotyJohnathanSaxman: Yes. – Drew Feb 17 '15 at 2:57
4

Within the context of development if you are appling some CRUD changes in one operation I usually opt for "sync" or "synchronize" as a method name.

4

I believe it was mentioned in a comment, but Store is very applicable.

Moreover, Store matches in character count to Fetch, which, if you're insane like me, is a quality you value in naming conventions.

function store(val: *);

function fetch(key: *);

function erase(key: *); // or purge()
  • 2
    +1 for acknowledging your own insanity, which I share, to be honest. – undefined Oct 29 '18 at 23:16
2

In SQL terminology merge term is used for this: https://en.wikipedia.org/wiki/Merge_(SQL)

This is a synonym of upsert (update + insert) which, in my opinion, suits even better, because its meaning is explicit.

1

Populate may be appropriate. When you create or update an object, you typically "populate" the object with new property values.

1

Key-Value stores often use put to create/update and get to retrieve.

I'm late to the party but mention it because save (the accepted and popular answer) suggests that the thing being created or updated is persisted as well. That might or might not be the case. Often persisting is within transactions and done with commit. So if you use save to create or update the object it might still not be saved. In fact, usually isn't saved.

0

I am using upinit "word" for this. In DB world, there is upsert (update or insert). Why not to have update or init?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.