Are stepwise refinement and refactoring the same thing Provi

Are stepwise refinement and refactoring the same thing? Provide a detailed example of each and describe why they are different (or the same)

Solution

No, stepwise refinement and refactoring or not the same.

Stepwise Refinement

Refactoring

Stepwise refinement is a design strategy that is used for splitting up a system into different chunks or modules and then modifying each module step by step to develop it further.

Refactoring is a technique to improve the quality of existing code. It works by applying a number of steps, each of which changes the internal structure of the code, while maintaining its external behavior.

It adds code to implement the functionality.

It removes any redundant code to improve quality.

Example:

public class Student{

        protected String name;

        public Student(String name){

               this.name = name;

        }

        public Student(){};

        public String getName(){

               return name;

        }

        public String toString(){

               return name;

        }

}

In the above example we have two constructors, one parameterized and one default.

Say, we have a main function as follows,

public static void main(String args[])

{

Student student = new Student();

String name = student.getName();

}

This will result in NullPointereException since student is not initialized with a name. But then the function call still happens. In this case, there should be a check to see if the value is null or not.

Such kind of refinement is done in this strategy

Example:

public class Student{

        protected String name;

        public Student(String name){

               this.name = name;

        }

        public Student(){};

        public String getName(){

               return name;

        }

        public String toString(){

               return name;

        }

}

Let us consider the same example .

The functions getName() and toString() are returning the same value, thereby they become redundant.

This strategy is for removing such redundancies in code to improve the quality and performance.

Stepwise Refinement

Refactoring

Stepwise refinement is a design strategy that is used for splitting up a system into different chunks or modules and then modifying each module step by step to develop it further.

Refactoring is a technique to improve the quality of existing code. It works by applying a number of steps, each of which changes the internal structure of the code, while maintaining its external behavior.

It adds code to implement the functionality.

It removes any redundant code to improve quality.

Example:

public class Student{

        protected String name;

        public Student(String name){

               this.name = name;

        }

        public Student(){};

        public String getName(){

               return name;

        }

        public String toString(){

               return name;

        }

}

In the above example we have two constructors, one parameterized and one default.

Say, we have a main function as follows,

public static void main(String args[])

{

Student student = new Student();

String name = student.getName();

}

This will result in NullPointereException since student is not initialized with a name. But then the function call still happens. In this case, there should be a check to see if the value is null or not.

Such kind of refinement is done in this strategy

Example:

public class Student{

        protected String name;

        public Student(String name){

               this.name = name;

        }

        public Student(){};

        public String getName(){

               return name;

        }

        public String toString(){

               return name;

        }

}

Let us consider the same example .

The functions getName() and toString() are returning the same value, thereby they become redundant.

This strategy is for removing such redundancies in code to improve the quality and performance.

Are stepwise refinement and refactoring the same thing? Provide a detailed example of each and describe why they are different (or the same)SolutionNo, stepwise
Are stepwise refinement and refactoring the same thing? Provide a detailed example of each and describe why they are different (or the same)SolutionNo, stepwise
Are stepwise refinement and refactoring the same thing? Provide a detailed example of each and describe why they are different (or the same)SolutionNo, stepwise

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site