forked from nus-cs2103-AY2324S2/tp
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #179 from quelinxiao/update-tutorial-files
refactor person to employee in tutorial files
- Loading branch information
Showing
4 changed files
with
54 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
> — Antoine de Saint-Exupery | ||
When working on an existing code base, you will most likely find that some features that are no longer necessary. | ||
This tutorial aims to give you some practice on such a code 'removal' activity by removing the `address` field from `Person` class. | ||
This tutorial aims to give you some practice on such a code 'removal' activity by removing the `address` field from `Employee` class. | ||
|
||
<box type="success"> | ||
|
||
|
@@ -31,7 +31,7 @@ IntelliJ IDEA provides a refactoring tool that can identify *most* parts of a re | |
|
||
### Assisted refactoring | ||
|
||
The `address` field in `Person` is actually an instance of the `seedu.address.model.employee.Address` class. Since removing the `Address` class will break the application, we start by identifying `Address`'s usages. This allows us to see code that depends on `Address` to function properly and edit them on a case-by-case basis. Right-click the `Address` class and select `Refactor` \> `Safe Delete` through the menu. | ||
The `address` field in `Employee` is actually an instance of the `seedu.address.model.employee.Address` class. Since removing the `Address` class will break the application, we start by identifying `Address`'s usages. This allows us to see code that depends on `Address` to function properly and edit them on a case-by-case basis. Right-click the `Address` class and select `Refactor` \> `Safe Delete` through the menu. | ||
* :bulb: To make things simpler, you can unselect the options `Search in comments and strings` and `Search for text occurrences` | ||
|
||
 | ||
|
@@ -40,11 +40,11 @@ Choose to `View Usages` and you should be presented with a list of `Safe Delete | |
|
||
 | ||
|
||
Remove usages of `Address` by performing `Safe Delete`s on each entry i.e., double-click on the entry (which takes you to the code in concern, right-click on that entity, and choose `Refactor` -> `Safe delete` as before). You will need to exercise discretion when removing usages of `Address`. Functions like `ParserUtil#parseAddress()` can be safely removed but its usages must be removed as well. Other usages like in `EditPersonDescriptor` may require more careful inspection. | ||
Remove usages of `Address` by performing `Safe Delete`s on each entry i.e., double-click on the entry (which takes you to the code in concern, right-click on that entity, and choose `Refactor` -> `Safe delete` as before). You will need to exercise discretion when removing usages of `Address`. Functions like `ParserUtil#parseAddress()` can be safely removed but its usages must be removed as well. Other usages like in `EditEmployeeDescriptor` may require more careful inspection. | ||
|
||
Let’s try removing references to `Address` in `EditPersonDescriptor`. | ||
Let’s try removing references to `Address` in `EditEmployeeDescriptor`. | ||
|
||
1. Safe delete the field `address` in `EditPersonDescriptor`. | ||
1. Safe delete the field `address` in `EditEmployeeDescriptor`. | ||
|
||
1. Select `Yes` when prompted to remove getters and setters. | ||
|
||
|
@@ -55,7 +55,7 @@ Let’s try removing references to `Address` in `EditPersonDescriptor`. | |
|
||
<box type="tip" seamless> | ||
|
||
**Tip:** Removing usages may result in errors. Exercise discretion and fix them. For example, removing the `address` field from the `Person` class will require you to modify its constructor. | ||
**Tip:** Removing usages may result in errors. Exercise discretion and fix them. For example, removing the `address` field from the `Employee` class will require you to modify its constructor. | ||
</box> | ||
|
||
1. Repeat the steps for the remaining usages of `Address` | ||
|
@@ -66,13 +66,13 @@ After you are done, verify that the application still works by compiling and run | |
|
||
Unfortunately, there are usages of `Address` that IntelliJ IDEA cannot identify. You can find them by searching for instances of the word `address` in your code (`Edit` \> `Find` \> `Find in path`). | ||
|
||
Places of interest to look out for would be resources used by the application. `main/resources` contains images and `fxml` files used by the application and `test/resources` contains test data. For example, there is a `$address` in each `PersonCard` that has not been removed nor identified. | ||
Places of interest to look out for would be resources used by the application. `main/resources` contains images and `fxml` files used by the application and `test/resources` contains test data. For example, there is a `$address` in each `EmployeeCard` that has not been removed nor identified. | ||
|
||
 | ||
|
||
A quick look at the `PersonCard` class and its `fxml` file quickly reveals why it slipped past the automated refactoring. | ||
A quick look at the `EmployeeCard` class and its `fxml` file quickly reveals why it slipped past the automated refactoring. | ||
|
||
**`PersonCard.java`** | ||
**`EmployeeCard.java`** | ||
|
||
```java | ||
... | ||
|
@@ -81,7 +81,7 @@ private Label address; | |
... | ||
``` | ||
|
||
**`PersonCard.fxml`** | ||
**`EmployeeCard.fxml`** | ||
|
||
``` xml | ||
... | ||
|
@@ -99,12 +99,12 @@ At this point, your application is working as intended and all your tests are pa | |
|
||
In `src/test/data/`, data meant for testing purposes are stored. While keeping the `address` field in the json files does not cause the tests to fail, it is not good practice to let cruft from old features accumulate. | ||
|
||
**`invalidPersonAddressBook.json`:** | ||
**`invalidEmployeeAddressBook.json`:** | ||
|
||
```json | ||
{ | ||
"employees": [ { | ||
"name": "Person with invalid name field: Ha!ns Mu@ster", | ||
"name": "Employee with invalid name field: Ha!ns Mu@ster", | ||
"phone": "9482424", | ||
"email": "[email protected]", | ||
"address": "4th street" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters