Leveraging Human Capital
August 11, 2021
Qualities of a Nurse Leader
August 11, 2021

answers 1597423 2

Question #3 – Refactoring Programs

Refactor the following code; i.e. improve its quality without modifying its behavior;

  • Use meaningful names for variables, parameters & functions

  • Provide proper documentation as required in the PAs

  • Provide proper indentation & programming style similar to the examples from the textbook, videos & PAs

  • Remove useless code

  • Simplify program

  • Improve performance

You will provide your version in the “Your Modified Version” subsection which is already pre-filled with the original. Then, for each improvement you applied, use the table in the “Summary” subsection to explain what you did & why you did it.

Program to Refactor

  1. int mystery(int v1, int v2){

  2. if( (v1 < 1) || (v2 < 1) ) return 0;

  3. if( v1 < v2 ) return mystery(v1, v2-1)+1;

  4. if( v2 < v1 ) return mystery(v1-1, v2)+1;

  5. return mystery(v1-1, v2-1);

  6. }

Your Improved Version

  1. int mystery(int v1, int v2){

  2. if( (v1 < 1) || (v2 < 1) ) return 0;

  3. if( v1 < v2 ) return mystery(v1, v2-1)+1;

  4. if( v2 < v1 ) return mystery(v1-1, v2)+1;

  5. return mystery(v1-1, v2-1);

  6. }

Summary of Improvements

 

Feel free to add rows to, or remove rows from, this table as needed;

 
Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount!
Use Discount Code "Newclient" for a 15% Discount!

NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.

Buy Custom Nursing Papers