Skip to content

Commit 4acfa2d

Browse files
authored
Update task.md
language checked
1 parent 44f28c5 commit 4acfa2d

File tree

1 file changed

+11
-11
lines changed
  • RefactoringAndItsPurpose/WhatIsCodeRefactoring/Theory

1 file changed

+11
-11
lines changed

RefactoringAndItsPurpose/WhatIsCodeRefactoring/Theory/task.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Task 1/2: What is code refactoring?
22

3-
**_Refactoring_** is a process of modifying source code without changing its behavior. For example, renaming a method or
4-
extracting a _magic constant_ into a separate variable. It improves code readability but doesn’t change what code does.
3+
**_Refactoring_** is a process of modifying source code without changing its behavior. For example, this could involve renaming a method or
4+
extracting a _magic constant_ into a separate variable. It improves code readability but doesn’t change what the code does.
55

6-
The purpose of refactoring is to **improve code readability and simplify its maintenance**. Usually, software developers
7-
work in teams on code bases and spend considerable time reading each other’s code, so it is important to make your code
6+
The purpose of refactoring is to **improve code readability and simplify its maintenance**. Since software developers often
7+
work in teams on codebases and spend considerable time reading each other’s code, it is important to make your code
88
clear and clean.
99

1010
Let's take a look at two code snippets below.
@@ -26,8 +26,8 @@ public class Main {
2626
}
2727
```
2828

29-
In this snippet of code, method name `calculate` isn't descriptive, making it unclear what it calculates.
30-
Variable `n` and method parameter `r` don't provide any information about their purpose.
29+
In this snippet of code, the method name `calculate` isn't descriptive, making it unclear what it calculates.
30+
The variable `n` and the method parameter `r` don't provide any information about their purpose.
3131
The constant `3.14159` is hard-coded within the method, leading to lack of clarity.
3232

3333
**After refactoring:**
@@ -49,11 +49,11 @@ public class Main {
4949
}
5050
```
5151

52-
To improve readability of the original snippet of code, the following refactorings were applied:
52+
To improve the readability of the original snippet of code, the following refactorings were applied:
5353

54-
- Method `calculate` was **renamed** to `calculateCircleArea` to better express its purpose: calculating the area of a
54+
- The method `calculate` was **renamed** to `calculateCircleArea` to better express its purpose: calculating the area of a
5555
circle.
56-
- Variable `n` was **renamed** to `circleRadius` for better code clarity.
57-
- Parameter `r` was **renamed** to `radius` for better code clarity.
58-
- `PI_VALUE` constant was **extracted** to hold the value of `Pi` value, making the calculation formula more
56+
- The variable `n` was **renamed** to `circleRadius` for better code clarity.
57+
- The parameter `r` was **renamed** to `radius` to improve code clarity.
58+
- A `PI_VALUE` constant was **extracted** to hold the value of `Pi`, making the calculation formula more
5959
understandable and reusable.

0 commit comments

Comments
 (0)