pixtur:Antwort auf set is a more common prefix for functions that update/inserts information.
7 years ago (2. update 6 years ago)
Wouldn't the suffix like "new" / "edit" be sufficient? But otherwise, streber's API should not be too far away from other solutions.
idolpx:Reply to Antwort auf set is a more common prefix for functions that update/inserts information.
6 years ago
Maybe "add" for new items?
6 years ago
The ideal way to design such function is to use only one function for all createing/updating, and this would normally be called set_ObjectName.
The thing separating a create from an insert would be the presence of an identificator.
So for instance, if I give the function set_object an object without an identificator it would create the element and return the new Id, if I give it an object with an identificator it would simply update it. In some projects I have this is actually implemented in the stored procedure stored in the database. So all functions in my normal code uses the set_object knowing that as long as the returned value is not 0, the object is created/updated.
In this way, the developer seldoms needs to think about this being an update or an insert, just call set_object and you will get back the new/current id.
On the naming convention, set_ and get_ is extremely common in most frameworks.
6 years ago
set/get also helps when creating dynamic function calls. Just prepend get_ to the objects class name to retrieve and set_ to save.
idolpx:Reply to considered REST?
6 years ago
REST sounds good to me. :)