Which one is easier to develop and work with (which saves the most time)? Which one would you go for? The name of the API represents its true purpose in this case by the way, createOrUpdate creates or updates the passed in meeting and create just creates the meeting. I will be the only one working on this project for now, although obviously, I would like others to work on it with me eventually.

  • JokersPistol@programming.devOP
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    2 years ago

    The only thing I can think of is when the user edits meetings en masse – say they’re rescheduling their whole day and are simultaneously creating and updating the timing of blocks. That probably will be functionality I’ll want to implement (allowing users to enter “edit mode” for their schedule).

    That’s a good question though, other than that case it wouldn’t be relevant. Plus, I probably would implement a createOrUpdateMeetings() API rather than createOrUpdateMeeting should that occur. Since Create and Update are both relatively simple APIs to implement, I think I’ll stick with those for now and possibly shift over to createOrUpdate if the need comes up. Thanks for the insight!

    Edit: After thinking about it and tinkering a bit more, I ended up going with the createOrUpdateMeetings() approach. At least on the surface, it seems simpler and cleaner for my use case – there will be times where my client will have a list of both existing and new meetings to send over. Still open to suggestions from everyone though, people have made good points.

    • sbv
      link
      fedilink
      English
      arrow-up
      1
      ·
      2 years ago

      If the function is doing input validation, it might be cleaner to have a single code path for both creation and update. Especially if you eventually assemble an SQL statement that is INSERT OR UPDATE.