From d50dbbc7a05da06e1edf1415bcb8765d3e65ecd5 Mon Sep 17 00:00:00 2001 From: stephen-hero <78870893+stephen-hero@users.noreply.github.com> Date: Mon, 22 Jan 2024 14:44:07 +0200 Subject: [PATCH] Update task.md language checked --- .../WhatIsExtractMethodRefactoring/Theory/task.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ExtractingCode/WhatIsExtractMethodRefactoring/Theory/task.md b/ExtractingCode/WhatIsExtractMethodRefactoring/Theory/task.md index 96e50bd..45d261a 100644 --- a/ExtractingCode/WhatIsExtractMethodRefactoring/Theory/task.md +++ b/ExtractingCode/WhatIsExtractMethodRefactoring/Theory/task.md @@ -1,18 +1,18 @@ # Task 1/2: What is Extract Method refactoring? -As we mentioned before, **duplicated code can lead to undesirable effects**, such as when you fix a bug in one place -but forget to fix it consistently in duplicates. -The bug will still remain, and now it is even harder to find. +As we mentioned before, **duplicated code can lead to undesirable effects**. For example, if you fix a bug in one place +but forget to fix it consistently in duplicates, +the bug will still remain, and now it is even harder to find. We recommend avoiding duplicated code, but what can you do if it already exists? The solution is to **extract the duplicated code into a new separate function** and replace all the duplicated code fragments with calls to the newly introduced function. -It is called an **Extract Method**. +It is called the **Extract Method**. -Also, we apply Extract Method refactoring when we encounter **long methods**. -While there's no fixed limit on the number of lines a method should have, **consider extracting +Also, we apply the Extract Method refactoring when we encounter **long methods**. +While there's no fixed limit on a method's line count should have, **consider extracting a block of code statements into a separate method** if those statements are cohesive -and expose a piece of functionality that can be reused in other places. +and represent a piece of functionality that could be reused elsewhere. This also improves code readability and organization. Smaller functions make the code easier to read and understand, as each method has one single responsibility,