From 32ab1dae2e0d154a52d27e8dad08597499044bb3 Mon Sep 17 00:00:00 2001 From: Zarina Kurbatova Date: Thu, 26 Oct 2023 14:24:04 +0200 Subject: [PATCH] Polishing --- .../CodeSchemasAndEditorConfig/Theory/task.md | 4 +++- .../WhatIsFormatting/ReformatTheCodeUsingIDE/task.md | 10 ++++++++-- .../WhatIsExtractMethodRefactoring/Theory/task.md | 12 ++++++------ .../WhatIsInlineVariableRefactoring/Theory/task.md | 4 ++-- .../Theory/task.md | 2 +- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/CodeStyleAndFormatting/CodeSchemasAndEditorConfig/Theory/task.md b/CodeStyleAndFormatting/CodeSchemasAndEditorConfig/Theory/task.md index a2c378b..eac1006 100644 --- a/CodeStyleAndFormatting/CodeSchemasAndEditorConfig/Theory/task.md +++ b/CodeStyleAndFormatting/CodeSchemasAndEditorConfig/Theory/task.md @@ -19,7 +19,9 @@ To configure the **code schema**, 3. Select the code schema you would like to configure (Project or Default). 4. Configure code style settings, such as tabs and indents, import settings (using single name import or import with `*`), and many others. -![Code Style](../../../util/src/main/resources/images/CodeStyleAndFormatting/CodeSchemasAndEditorConfig/code_style.png) +

+ Code Style +

### EditorConfig diff --git a/CodeStyleAndFormatting/WhatIsFormatting/ReformatTheCodeUsingIDE/task.md b/CodeStyleAndFormatting/WhatIsFormatting/ReformatTheCodeUsingIDE/task.md index 89fd63f..83e85e2 100644 --- a/CodeStyleAndFormatting/WhatIsFormatting/ReformatTheCodeUsingIDE/task.md +++ b/CodeStyleAndFormatting/WhatIsFormatting/ReformatTheCodeUsingIDE/task.md @@ -1,4 +1,6 @@ -In this lesson, you will learn a very useful shortcut that will format your code automatically according to the project’s settings. +### Task + +In this task, you will learn a very useful shortcut that will format your code automatically according to the project’s settings. To perform any refactoring in the IDE, you can use the Refactoring Menu or a specific shortcut. It’s also possible to configure custom shortcuts. @@ -12,7 +14,11 @@ In this dialog, you can specify the scope of formatting changes and select the o - **Code cleanup** option runs code cleanup inspections. - **Do not keep line breaks** option reformats line breaks according to the code style settings. -![Reformat File](../../../util/src/main/resources/images/CodeStyleAndFormatting/WhatIsFormatting/reformat_dialog.png) +

+ Reformat dialog +

+ +### Hints
Use &shortcut:ReformatCode; (macOS) or Ctrl + Alt + L (Windows/Linux) to reformat code. diff --git a/ExtractingCode/WhatIsExtractMethodRefactoring/Theory/task.md b/ExtractingCode/WhatIsExtractMethodRefactoring/Theory/task.md index 56110b8..5f4665c 100644 --- a/ExtractingCode/WhatIsExtractMethodRefactoring/Theory/task.md +++ b/ExtractingCode/WhatIsExtractMethodRefactoring/Theory/task.md @@ -1,15 +1,15 @@ -As we mentioned before, duplicated code can lead to undesirable effects, such as when you fix a bug in one place +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. 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 +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 Function. +It is called an **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 -a block of code statements into a separate method if those statements are cohesive +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 +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. This also improves code readability and organization. diff --git a/InliningCode/WhatIsInlineVariableRefactoring/Theory/task.md b/InliningCode/WhatIsInlineVariableRefactoring/Theory/task.md index a8ee686..887cdfb 100644 --- a/InliningCode/WhatIsInlineVariableRefactoring/Theory/task.md +++ b/InliningCode/WhatIsInlineVariableRefactoring/Theory/task.md @@ -3,8 +3,8 @@ We apply the **Inline refactoring** to simplify code by removing an unnecessary method or variable declarations and directly replacing them with their respective expressions or values. -Apply Inline Variable when a variable is only used once or when its name does not add any meaningful information. -If the variable does not contribute to code readability or logic, it can be inlined. +Apply Inline Variable when a **variable is only used once** or when its name does not add any meaningful information. +**If the variable does not contribute to code readability or logic, it can be inlined**. To apply the Inline Method refactoring, select the code you want to inline and press the &shortcut:Inline; (macOS) or `Ctrl+Alt+N` (Windows/Linux) shortcut. diff --git a/RefactoringAndItsPurpose/GettingFamiliarWithIDERefactoringFeatures/Theory/task.md b/RefactoringAndItsPurpose/GettingFamiliarWithIDERefactoringFeatures/Theory/task.md index 90d1d15..265352e 100644 --- a/RefactoringAndItsPurpose/GettingFamiliarWithIDERefactoringFeatures/Theory/task.md +++ b/RefactoringAndItsPurpose/GettingFamiliarWithIDERefactoringFeatures/Theory/task.md @@ -25,7 +25,7 @@ To open the **Search Everywhere** dialog, press **⇧⇧** (macOS) or **Shift+Sh For example, if you want to extract a function or explore any extract possibilities in the IDE, open the **Search Everywhere** dialog, type “Extract”, and it will show the available options.

- Search Everywhere + Search Everywhere

Moreover, for some refactorings, IntelliJ IDEA allows users to see the preview before applying changes.