If two employees working on same object triggers in salesforce how to expection desire output
Answers
The reason why it’s not is simple: Say that accidently two Developers working on your Org created two Apex Triggers on the Account object both running on the After Update instance. This happened since both of them are working remotely/independently and in fact one of the Apex Trigger by one developer was done a couple of weeks or months ago.
Now since both of them are running on the same instance (After Update) we cannot determine which Apex Trigger (out of the 2 After Updates) executes first. At times you would notice the one written by the former Developer runs first and at times the one written by the latter executes. Thus it could be a mess and your Business need might require the first one (the one written by the Developer about a month ago) to be triggered first. You now have no option since the order of execution of the Apex Triggers is wholly in the hand of the Platform.
It’s pretty much similar arranging a shelf of books where you have the Fiction on top, then Sci-Fi on the 2nd row and so on. Now, when you come in search on a Sci-Fi, you’d definitely know it’s on the 2nd row and you can jump straight to that in search of the book.
It’s the same way that you follow here: You’ll create an Apex Class (the shelf) and create Public Member Functions (rows in the shelf) each of which represent a business logic (when compared to the above example, one method would be the logic written by the former Developer and the other method would be the logic written by the latter Developer).
Now, within the Apex Trigger, you can instantiate the Apex Class and then it’s up to you as to when you should be invoking the first member function and the 2nd one. Thus you have a control in the order of execution. If the Business required the lastly written to be executed first, then all you have to do is to just swap the functions calls!
So this is just brief idea and like as mentioned by Thenmozhi you have many Trigger Templates out there which you can utilize in order to re-factor/architect the Apex Triggers that have.