-1

The application should records some tasks occurrence in the Database. The question is: Save or update the task first then perform the task, or perform the task first then save or update to the Database?

Logically, I bit that doing the task first and then save to the database is better. However, in transactional environment which should offer rollback mechanism to the database, I think doing the task under the cover of transaction is better, i.e. Update first then do the task!

What do you think about this?

1 Answers1

0

What matters is that your processes are atomic, which means that as long a you rollback everything in case of an exception what you do first or last shouldnt matter.

Well it might matter if you need the generated id of your task class to continue.

ryudice
  • 36,476
  • 32
  • 115
  • 163