Skip to content

Commit d419eab

Browse files
committed
add refactoring description
Signed-off-by: Shi Chen <chenshi@microsoft.com>
1 parent 4e83f55 commit d419eab

2 files changed

Lines changed: 38 additions & 1 deletion

File tree

document/_java.learnMoreAboutRefactorings.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
- [Inline constant](#inline-constant)
1919
- [Inline local variable](#inline-local-variable)
2020
- [Inline method](#inline-method)
21-
- [Introduce Parameter](#introduce-parameter)
21+
- Method signature
22+
- [Introduce Parameter](#introduce-parameter)
23+
- [Change method signature](#change-method-signature)
2224
- Invert boolean
2325
- [Invert conditions](#invert-conditions)
2426
- [Invert local variable](#invert-local-variable)
@@ -469,6 +471,41 @@ public void addUser(String name) {
469471
}
470472
```
471473

474+
---
475+
476+
## Change Method Signature
477+
Changes the method visibility, return type, name, and updates the parameters and exceptions. The above changes can be applied through the call hierarchy of the method.
478+
479+
### Example
480+
Let's change signature for the method `public void setAddress(String address)`.
481+
482+
#### Before
483+
484+
```java
485+
public void setAddress(String address) {
486+
this.address = address;
487+
}
488+
489+
public void setAddr() {
490+
this.setAddress("Addr");
491+
}
492+
```
493+
494+
#### Refactor configuration
495+
496+
![change_signature](./refactoring_change_signature.png)
497+
#### After
498+
```java
499+
public void setAddress1(Object newParam, String address) {
500+
this.address = address;
501+
}
502+
503+
public void setAddr() {
504+
this.setAddress1(null, "Addr");
505+
}
506+
```
507+
---
508+
472509
## Invert conditions
473510
Inverts the boolean expression in the conditions.
474511

32.8 KB
Loading

0 commit comments

Comments
 (0)