Coding best practices to overcome merge conflicts?

Navitrans_fvet
Member Posts: 9
In an attempt trying to understand the merge commandlet and dealing with conflicts, I came accross some situations I would like to get some more explanations about the 'why' of these conflict situations.
Example 1 (OnModify Customer)
Original code
Target code (recent cumulative update)
I'm experiencing several similar conflict situations on changes in the modified / target version on adjacent lines. Are there any best practices to come around these type of conflicts?
Example 2
If the requirement would be not to get the salesperson from the customer, but to get if from the user setup (using a custom field), how would one best integrate this change?
Original code
- Embedding the original code in a surrounding IF THEN (or via a preceding function) might be an option. In that case, it's advised not to change the indentation I guess?
- Leave the code 'as is' and add the modified code at the end (or via eventing in 2016). This would execute the redundant original code / database calls whereas it's no longer needed.
Example 1 (OnModify Customer)
Original code
... MODIFY; CallSyncCodeunit; FIND; ...Modified code
... MODIFY; CallSyncCodeunit; CallOtherSyncCodeunit; // Added FIND; ...The above would automatically merge without any conflicts, if my target version would remain unchanged. However, if changes are applied to the target version, the modified change can no longer be automatically merged and a conflict is created.
Target code (recent cumulative update)
MODIFY; CallSyncCodeunit; IF FIND THEN; // Added IF THENIf you look at the code on a line by line level, the delta between original / modified is
CallOtherSyncCodeunit; // Addedand the delta between original / target is
IF FIND THEN; // Added IF THENSo why can't both deltas be applied to the result version?
I'm experiencing several similar conflict situations on changes in the modified / target version on adjacent lines. Are there any best practices to come around these type of conflicts?
Example 2
If the requirement would be not to get the salesperson from the customer, but to get if from the user setup (using a custom field), how would one best integrate this change?
Original code
... IF Customer.GET("Customer No.") THEN "Salesperson Code":= Customer."Salesperson Code"; ...Modified code
... IF UserSetup.GET(USERID) THEN "Salesperson Code":= UserSetup."Salesperson Code"; ...- Commenting the original code would lead to a conflict if the target code is changed.
- Embedding the original code in a surrounding IF THEN (or via a preceding function) might be an option. In that case, it's advised not to change the indentation I guess?
- Leave the code 'as is' and add the modified code at the end (or via eventing in 2016). This would execute the redundant original code / database calls whereas it's no longer needed.
0
Comments
-
You can check this link when the result of merge will be conflict
https://msdn.microsoft.com/en-us/library/hh997122(v=nav.71).aspx0 -
It sounds silly, but sometimes it is best to just let Microsoft do its thing and then overwrite their results with yours
So:
Customer.GET("Customer No.");
Customer.GET(USERID); // New Code
The result is effectively the same and won't lead to merge conflicts.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions