Model of Rationale for Code Commits

Component Component Expressed as Question Example Answer
Goal What did you want to achieve? I wanted to implement functionality to sort the product list by price.
Need Why did you need to achieve that? Our user requested to be able to sort the list of products by price.
Constraints What were the constraints limiting your implementation choice? The sorting algorithm had to be space efficient because it should work in embedded devices.
Alternatives What other alternatives did you have? I could have used the bucket sort algorithm, but this option is not feasible because I will not know the maximum price before sorting.
Selected Alternative Why did you make those specific changes and not others? I implemented heap sort because it is space efficient and it has predictable speed.
Dependency What other changes does this change depend on? This change depends on the API that provides the product list to be updated to use JSON format.
Validation How did those specific changes achieve the goal? By using the heap sort algorithm, our customers can now see a sorted product list in their memory-limited hardware.
Committer Who changed the code? Developer X, who is responsible for the “products” page.
Time Why were the changes made at that time? This change happened before our 3.0 release to meet the customer contract for that release.
Maturity Stage How mature is this code? The change is an initial implementation, which still has to be fully tested after the API for the products list is updated.
Location What artifacts were changed? The “product” class was updated.
Modifications What specific changes were performed in the artifacts? I added a “sort” method in the “product” class implementing heap sort and now the “listProduct” method calls “sort” first.
Explanation of Modifications What are the details of the implementation? The code sorts the products by price by performing the following steps:
  1. Build a heap from a list of “products” in O(n) operations.
  2. Swap the first list-element with the final list-element of the list.
  3. Decrease the considered range of the list by one.
  4. Shift the new first element to its appropriate index in the heap based on the “price”.
  5. Repeat step (2) unless the considered range of the list is one element.
Benefits What is the benefit of what you want to achieve? The new option of sorting products by price will be useful for many customers besides the one who requested it.
Side Effects What are the side effects of the change? The integration test will fail if the API that provides the product list is not updated. At the same time, merging this change with the main branch after updating the API might break the existing code. Also, our implementation of heap sort may be too complex for beginners and slow down maintenance.