Skip to content

Commit

Permalink
Polishing
Browse files Browse the repository at this point in the history
  • Loading branch information
onewhl committed Oct 26, 2023
1 parent 6b48382 commit 32ab1da
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
<p align="center">
<img src="../../../util/src/main/resources/images/CodeStyleAndFormatting/CodeSchemasAndEditorConfig/code_style.png" alt="Code Style" width="400"/>
</p>

### EditorConfig

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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)
<p align="center">
<img src="../../../util/src/main/resources/images/CodeStyleAndFormatting/WhatIsFormatting/reformat_dialog.png" alt="Reformat dialog" width="400"/>
</p>

### Hints

<div class="hint" title="Shortcut to reformat code">
Use &shortcut:ReformatCode; (macOS) or Ctrl + Alt + L (Windows/Linux) to reformat code.
Expand Down
12 changes: 6 additions & 6 deletions ExtractingCode/WhatIsExtractMethodRefactoring/Theory/task.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
4 changes: 2 additions & 2 deletions InliningCode/WhatIsInlineVariableRefactoring/Theory/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Original file line number Diff line number Diff line change
Expand Up @@ -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.
<p align="center">
<img src="../../../util/src/main/resources/images/RefactoringAndItsPurpose/GettingFamiliarWithIDERefactoringFeatures/search_everywhere.png" alt="Search Everywhere" width="500"/>
<img src="../../../util/src/main/resources/images/RefactoringAndItsPurpose/GettingFamiliarWithIDERefactoringFeatures/search_everywhere.png" alt="Search Everywhere" width="400"/>
</p>

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

0 comments on commit 32ab1da

Please sign in to comment.