diff --git a/RefactoringAndItsPurpose/WhatIsCodeRefactoring/Theory/task.md b/RefactoringAndItsPurpose/WhatIsCodeRefactoring/Theory/task.md index 418fd4e..91bbc7f 100644 --- a/RefactoringAndItsPurpose/WhatIsCodeRefactoring/Theory/task.md +++ b/RefactoringAndItsPurpose/WhatIsCodeRefactoring/Theory/task.md @@ -1,10 +1,10 @@ # Task 1/2: What is code refactoring? -**_Refactoring_** is a process of modifying source code without changing its behavior. For example, renaming a method or -extracting a _magic constant_ into a separate variable. It improves code readability but doesn’t change what code does. +**_Refactoring_** is a process of modifying source code without changing its behavior. For example, this could involve renaming a method or +extracting a _magic constant_ into a separate variable. It improves code readability but doesn’t change what the code does. -The purpose of refactoring is to **improve code readability and simplify its maintenance**. Usually, software developers -work in teams on code bases and spend considerable time reading each other’s code, so it is important to make your code +The purpose of refactoring is to **improve code readability and simplify its maintenance**. Since software developers often +work in teams on codebases and spend considerable time reading each other’s code, it is important to make your code clear and clean. Let's take a look at two code snippets below. @@ -26,8 +26,8 @@ public class Main { } ``` -In this snippet of code, method name `calculate` isn't descriptive, making it unclear what it calculates. -Variable `n` and method parameter `r` don't provide any information about their purpose. +In this snippet of code, the method name `calculate` isn't descriptive, making it unclear what it calculates. +The variable `n` and the method parameter `r` don't provide any information about their purpose. The constant `3.14159` is hard-coded within the method, leading to lack of clarity. **After refactoring:** @@ -49,11 +49,11 @@ public class Main { } ``` -To improve readability of the original snippet of code, the following refactorings were applied: +To improve the readability of the original snippet of code, the following refactorings were applied: -- Method `calculate` was **renamed** to `calculateCircleArea` to better express its purpose: calculating the area of a +- The method `calculate` was **renamed** to `calculateCircleArea` to better express its purpose: calculating the area of a circle. -- Variable `n` was **renamed** to `circleRadius` for better code clarity. -- Parameter `r` was **renamed** to `radius` for better code clarity. -- `PI_VALUE` constant was **extracted** to hold the value of `Pi` value, making the calculation formula more +- The variable `n` was **renamed** to `circleRadius` for better code clarity. +- The parameter `r` was **renamed** to `radius` to improve code clarity. +- A `PI_VALUE` constant was **extracted** to hold the value of `Pi`, making the calculation formula more understandable and reusable.