Skip to content

Commit 33c0ea1

Browse files
authored
Merge pull request nus-cs2103-AY2021S1#74 from GeNiaaz/refactor-Project-Address
Refactor Address to ProjectDescription
2 parents 7025aa4 + e973996 commit 33c0ea1

37 files changed

+296
-261
lines changed

config/checkstyle/checkstyle.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@
213213
some other variants which we don't publicized to promote consistency).
214214
-->
215215
<property name="reliefPattern"
216-
value="fall through|Fall through|fallthru|Fallthru|falls through|Falls through|fallthrough|Fallthrough|No break|NO break|no break|continue on"/>
216+
value="fall through|Fall through|fallthru|Fallthru|falls through|Falls through|fallthrough
217+
|Fallthrough|No break|NO break|no break|continue on"/>
217218
</module>
218219

219220
<module name="MissingSwitchDefault"/>

docs/Configuration.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ layout: page
33
title: Configuration guide
44
---
55

6-
Certain properties of the application can be controlled (e.g user preferences file location, logging level) through the configuration file (default: `config.json`).
6+
Certain properties of the application can be controlled (e.g user preferences file location, logging level) through
7+
the configuration file (default: `config.json`).

docs/DeveloperGuide (original AB3 tempalte).md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ The ***Architecture Diagram*** given above explains the high-level design of the
3131

3232
</div>
3333

34-
**`Main`** has two classes called [`Main`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/Main.java) and
35-
[`MainApp`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/MainApp.java). It is responsible for,
34+
**`Main`** has two classes called
35+
[`Main`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/Main.java) and
36+
[`MainApp`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/MainApp.java). It is
37+
responsible for,
3638
* At app launch: Initializes the components in the correct sequence, and connects them up with each other.
3739
* At shut down: Shuts down the components and invokes cleanup methods where necessary.
3840

docs/DeveloperGuide.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ The ***Architecture Diagram*** given above explains the high-level design of the
2727

2828
</div>
2929

30-
**`Main`** has two classes called [`Main`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/Main.java) and [`MainApp`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu/address/MainApp.java). It is responsible for,
30+
**`Main`** has two classes called [`Main`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java
31+
/seedu/address/Main.java) and [`MainApp`](https://github.com/se-edu/addressbook-level3/tree/master/src/main/java/seedu
32+
/address/MainApp.java). It is responsible for,
3133
* At app launch: Initializes the components in the correct sequence, and connects them up with each other.
3234
* At shut down: Shuts down the components and invokes cleanup methods where necessary.
3335

@@ -326,7 +328,7 @@ Use case ends.
326328
**MSS:**
327329

328330
1. Team leader create a new team member profile.
329-
2. TMTS asks for the details of the team member such as projectName, phone number and email address.
331+
2. TMTS asks for the details of the team member such as projectName, phone number and email projectDescription.
330332
3. Team leader keys in the details.
331333
4. TMTS stores the team member's profile into the data file.
332334

@@ -351,7 +353,7 @@ Use case ends.
351353
1. Team leader chooses to edit a team member's profile.
352354
2. PTS asks for the projectName of the team member whose profile is to be edited.
353355
3. Team leader keys in the projectName of the team member.
354-
4. TMTS asks for the new information of team member such as projectName, phone number and email address.
356+
4. TMTS asks for the new information of team member such as projectName, phone number and email projectDescription.
355357
5. Team leader keys in the details.
356358
6. TMTS stores the team member's profile into the data file.
357359

docs/_sass/minima/custom-styles.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ h2, h3, h4, h5, h6 {
2828

2929
@each $color, $value in $theme-colors {
3030
.alert-#{$color} {
31-
@include alert-variant(color-level($value, $alert-bg-level), color-level($value, $alert-border-level), color-level($value, $alert-color-level));
31+
@include alert-variant(color-level($value, $alert-bg-level), color-level($value, $alert-border-level),
32+
color-level($value, $alert-color-level));
3233
}
3334
}
3435

docs/tutorials/AddRemark.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ We start by modifying the constructor of `RemarkCommand` to accept an `Index` an
9393
if our code is functioning as intended.
9494

9595
``` java
96-
import static seedu.address.commons.util.CollectionUtil.requireAllNonNull;
96+
import static seedu.address
97+
.commons.util.CollectionUtil.requireAllNonNull;
9798
//...
9899
public class RemarkCommand extends Command {
99100
//...
@@ -143,7 +144,9 @@ Your code should look something like [this](https://github.com/se-edu/addressboo
143144

144145
Now let’s move on to writing a parser that will extract the index and remark from the input provided by the user.
145146

146-
Create a `RemarkCommandParser` class in the `seedu.address.logic.parser` package. The class must extend the `Parser` interface.
147+
Create a `RemarkCommandParser` class in the `seedu.address
148+
.logic.parser` package. The class must extend the `Parser
149+
` interface.
147150

148151
![The relationship between Parser and RemarkCommandParser](../images/add-remark/ParserInterface.png)
149152

@@ -235,7 +238,9 @@ Now that we have all the information that we need, let’s lay the groundwork fo
235238

236239
### Add a new `Remark` class
237240

238-
Create a new `Remark` in `seedu.address.model.project`. Since a `Remark` is a field that is similar to `Address`, we can reuse a significant bit of code.
241+
Create a new `Remark` in `seedu.address
242+
.model.project`. Since a `Remark` is a field that is similar to `Address`, we can
243+
reuse a significant bit of code.
239244

240245
A copy-paste and search-replace later, you should have something like
241246
[this](https://github.com/se-edu/addressbook-level3/commit/4516e099699baa9e2d51801bd26f016d812dedcc#diff-af2f075d24dfcd333876f0fbce321f25). Note how `Remark` has no
@@ -251,7 +256,9 @@ These should be relatively simple changes.
251256

252257
Without getting too deep into `fxml`, let’s go on a 5 minute adventure to get some placeholder text to show up for each project.
253258

254-
Simply add the following to [`seedu.address.ui.ProjectCard`](https://github.com/se-edu/addressbook-level3/commit/850b78879582f38accb05dd20c245963c65ea599#diff-0c6b6abcfac8c205e075294f25e851fe).
259+
Simply add the following to [`seedu.address
260+
.ui.ProjectCard`](https://github.com/se-edu/addressbook-level3/commit
261+
/850b78879582f38accb05dd20c245963c65ea599#diff-0c6b6abcfac8c205e075294f25e851fe).
255262

256263
**`ProjectCard.java`:**
257264

docs/tutorials/RemovingFields.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ title: "Tutorial: Removing Fields"
99
1010
When working on MainCatalogue, you will most likely find that some features and fields that are no longer necessary. In scenarios like this, you can consider refactoring the existing `Project` model to suit your use case.
1111

12-
In this tutorial, we’ll do exactly just that and remove the `address` field from `Project`.
12+
In this tutorial, we’ll do exactly just that and remove the `projectDescription` field from `Project`.
1313

1414
* Table of Contents
1515
{:toc}
@@ -20,7 +20,7 @@ Fortunately, IntelliJ IDEA provides a robust refactoring tool that can identify
2020

2121
### Assisted refactoring
2222

23-
The `address` field in `Project` is actually an instance of the `seedu.address.model.project.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.
23+
The `projectDescription` field in `Project` is actually an instance of the `seedu.address.model.project.ProjectDescriptionect.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.
2424

2525
![Usages detected](../images/remove/UnsafeDelete.png)
2626

@@ -32,18 +32,18 @@ Remove usages of `Address` by performing `Safe Delete`s on each entry. You will
3232

3333
Let’s try removing references to `Address` in `EditProjectDescriptor`.
3434

35-
1. Safe delete the field `address` in `EditProjectDescriptor`.
35+
1. Safe delete the field `projectDescription` in `EditProjectDescriptor`.
3636

3737
1. Select `Yes` when prompted to remove getters and setters.
3838

3939
1. Select `View Usages` again.<br>
4040
![UnsafeDeleteOnField](../images/remove/UnsafeDeleteOnField.png)
4141

42-
1. Remove the usages of `address` and select `Do refactor` when you are done.
42+
1. Remove the usages of `projectDescription` and select `Do refactor` when you are done.
4343

4444
<div markdown="span" class="alert alert-primary">
4545

46-
:bulb: **Tip:** Removing usages may result in errors. Exercise discretion and fix them. For example, removing the `address` field from the `Project` class will require you to modify its constructor.
46+
:bulb: **Tip:** Removing usages may result in errors. Exercise discretion and fix them. For example, removing the `projectDescription` field from the `Project` class will require you to modify its constructor.
4747
</div>
4848

4949
1. Repeat the steps for the remaining usages of `Address`
@@ -52,11 +52,11 @@ After you are done, verify that the application still works by compiling and run
5252

5353
### Manual refactoring
5454

55-
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`).
55+
Unfortunately, there are usages of `Address` that IntelliJ IDEA cannot identify. You can find them by searching for instances of the word `projectDescription` in your code (`Edit` \> `Find` \> `Find in path`).
5656

57-
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 `ProjectCard` that has not been removed nor identified.
57+
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 `$projectDescription` in each `ProjectCard` that has not been removed nor identified.
5858

59-
![$address](../images/remove/$address.png)
59+
![$projectDescription](../images/remove/$projectDescription.png)
6060

6161
A quick look at the `ProjectCard` class and its `fxml` file quickly reveals why it slipped past the automated refactoring.
6262

@@ -65,7 +65,7 @@ A quick look at the `ProjectCard` class and its `fxml` file quickly reveals why
6565
``` java
6666
...
6767
@FXML
68-
private Label address;
68+
private Label projectDescription;
6969
...
7070
```
7171

@@ -74,7 +74,7 @@ private Label address;
7474
``` xml
7575
...
7676
<Label fx:id="phone" styleClass="cell_small_label" text="\$phone" />
77-
<Label fx:id="address" styleClass="cell_small_label" text="\$address" />
77+
<Label fx:id="projectDescription" styleClass="cell_small_label" text="\$projectDescription" />
7878
<Label fx:id="email" styleClass="cell_small_label" text="\$email" />
7979
...
8080
```
@@ -85,7 +85,7 @@ After removing the `Label`, we can proceed to formally test our code. If everyth
8585

8686
At this point, your application is working as intended and all your tests are passing. What’s left to do is to clean up references to `Address` in test data and documentation.
8787

88-
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.
88+
In `src/test/data/`, data meant for testing purposes are stored. While keeping the `projectDescription` field in the json files does not cause the tests to fail, it is not good practice to let cruft from old features accumulate.
8989

9090
**`invalidProjectMainCatalogue.json`:**
9191

@@ -95,9 +95,9 @@ In `src/test/data/`, data meant for testing purposes are stored. While keeping t
9595
"projectName": "Project with invalid projectName field: Ha!ns Mu@ster",
9696
"phone": "9482424",
9797
"email": "[email protected]",
98-
"address": "4th street"
98+
"projectDescription": "4th street"
9999
} ]
100100
}
101101
```
102102

103-
You can go through each individual `json` file and manually remove the `address` field.
103+
You can go through each individual `json` file and manually remove the `projectDescription` field.

src/main/java/seedu/address/logic/commands/AddCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package seedu.address.logic.commands;
22

33
import static java.util.Objects.requireNonNull;
4-
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
54
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
65
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
6+
import static seedu.address.logic.parser.CliSyntax.PREFIX_PROJECT_DESCRIPTION;
77
import static seedu.address.logic.parser.CliSyntax.PREFIX_PROJECT_NAME;
88
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
99
import static seedu.address.logic.parser.CliSyntax.PREFIX_TASK;
@@ -24,14 +24,14 @@ public class AddCommand extends Command {
2424
+ PREFIX_PROJECT_NAME + "PROJECT NAME "
2525
+ PREFIX_PHONE + "PHONE "
2626
+ PREFIX_EMAIL + "EMAIL "
27-
+ PREFIX_ADDRESS + "ADDRESS "
27+
+ PREFIX_PROJECT_DESCRIPTION + "PROJECT DESCRIPTION "
2828
+ "[" + PREFIX_TAG + "TAG]...\n"
2929
+ "[" + PREFIX_TASK + "TASK]...\n"
3030
+ "Example: " + COMMAND_WORD + " "
3131
+ PREFIX_PROJECT_NAME + "John Doe "
3232
+ PREFIX_PHONE + "98765432 "
3333
+ PREFIX_EMAIL + "[email protected] "
34-
+ PREFIX_ADDRESS + "311, Clementi Ave 2, #02-25 "
34+
+ PREFIX_PROJECT_DESCRIPTION + "311, Clementi Ave 2, #02-25 "
3535
+ PREFIX_TAG + "friends "
3636
+ PREFIX_TAG + "owesMoney"
3737
+ PREFIX_TASK + "Write User Guide";

src/main/java/seedu/address/logic/commands/ClearCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
public class ClearCommand extends Command {
1212

1313
public static final String COMMAND_WORD = "clear";
14-
public static final String MESSAGE_SUCCESS = "Address book has been cleared!";
14+
public static final String MESSAGE_SUCCESS = "ProjectDescription book has been cleared!";
1515

1616

1717
@Override

src/main/java/seedu/address/logic/commands/EditCommand.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package seedu.address.logic.commands;
22

33
import static java.util.Objects.requireNonNull;
4-
import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS;
54
import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL;
65
import static seedu.address.logic.parser.CliSyntax.PREFIX_PHONE;
6+
import static seedu.address.logic.parser.CliSyntax.PREFIX_PROJECT_DESCRIPTION;
77
import static seedu.address.logic.parser.CliSyntax.PREFIX_PROJECT_NAME;
88
import static seedu.address.logic.parser.CliSyntax.PREFIX_TAG;
99
import static seedu.address.logic.parser.CliSyntax.PREFIX_TASK;
@@ -21,10 +21,10 @@
2121
import seedu.address.commons.util.CollectionUtil;
2222
import seedu.address.logic.commands.exceptions.CommandException;
2323
import seedu.address.model.Model;
24-
import seedu.address.model.project.Address;
2524
import seedu.address.model.project.Email;
2625
import seedu.address.model.project.Phone;
2726
import seedu.address.model.project.Project;
27+
import seedu.address.model.project.ProjectDescription;
2828
import seedu.address.model.project.ProjectName;
2929
import seedu.address.model.tag.Tag;
3030
import seedu.address.model.task.Task;
@@ -43,7 +43,7 @@ public class EditCommand extends Command {
4343
+ "[" + PREFIX_PROJECT_NAME + "PROJECTNAME] "
4444
+ "[" + PREFIX_PHONE + "PHONE] "
4545
+ "[" + PREFIX_EMAIL + "EMAIL] "
46-
+ "[" + PREFIX_ADDRESS + "ADDRESS] "
46+
+ "[" + PREFIX_PROJECT_DESCRIPTION + "PROJECTDESCRIPTION] "
4747
+ "[" + PREFIX_TAG + "TAG]...\n"
4848
+ "[" + PREFIX_TASK + "TASK]...\n"
4949
+ "Example: " + COMMAND_WORD + " 1 "
@@ -100,11 +100,12 @@ private static Project createEditedProject(Project projectToEdit, EditProjectDes
100100
ProjectName updatedProjectName = editProjectDescriptor.getProjectName().orElse(projectToEdit.getProjectName());
101101
Phone updatedPhone = editProjectDescriptor.getPhone().orElse(projectToEdit.getPhone());
102102
Email updatedEmail = editProjectDescriptor.getEmail().orElse(projectToEdit.getEmail());
103-
Address updatedAddress = editProjectDescriptor.getAddress().orElse(projectToEdit.getAddress());
103+
ProjectDescription updatedProjectDescription = editProjectDescriptor.getProjectDescription()
104+
.orElse(projectToEdit.getProjectDescription());
104105
Set<Tag> updatedTags = editProjectDescriptor.getTags().orElse(projectToEdit.getTags());
105106
Set<Task> updatedTasks = editProjectDescriptor.getTasks().orElse(projectToEdit.getTasks());
106107

107-
return new Project(updatedProjectName, updatedPhone, updatedEmail, updatedAddress,
108+
return new Project(updatedProjectName, updatedPhone, updatedEmail, updatedProjectDescription,
108109
updatedTags, new HashMap<>(), updatedTasks);
109110
}
110111

@@ -134,7 +135,7 @@ public static class EditProjectDescriptor {
134135
private ProjectName projectName;
135136
private Phone phone;
136137
private Email email;
137-
private Address address;
138+
private ProjectDescription projectDescription;
138139
private Set<Tag> tags;
139140
private Set<Task> tasks;
140141

@@ -148,7 +149,7 @@ public EditProjectDescriptor(EditProjectDescriptor toCopy) {
148149
setProjectName(toCopy.projectName);
149150
setPhone(toCopy.phone);
150151
setEmail(toCopy.email);
151-
setAddress(toCopy.address);
152+
setProjectDescription(toCopy.projectDescription);
152153
setTags(toCopy.tags);
153154
setTasks(toCopy.tasks);
154155
}
@@ -157,7 +158,7 @@ public EditProjectDescriptor(EditProjectDescriptor toCopy) {
157158
* Returns true if at least one field is edited.
158159
*/
159160
public boolean isAnyFieldEdited() {
160-
return CollectionUtil.isAnyNonNull(projectName, phone, email, address, tags, tasks);
161+
return CollectionUtil.isAnyNonNull(projectName, phone, email, projectDescription, tags, tasks);
161162
}
162163

163164
public void setProjectName(ProjectName projectName) {
@@ -184,12 +185,12 @@ public Optional<Email> getEmail() {
184185
return Optional.ofNullable(email);
185186
}
186187

187-
public void setAddress(Address address) {
188-
this.address = address;
188+
public void setProjectDescription(ProjectDescription projectDescription) {
189+
this.projectDescription = projectDescription;
189190
}
190191

191-
public Optional<Address> getAddress() {
192-
return Optional.ofNullable(address);
192+
public Optional<ProjectDescription> getProjectDescription() {
193+
return Optional.ofNullable(projectDescription);
193194
}
194195

195196
/**
@@ -244,7 +245,7 @@ public boolean equals(Object other) {
244245
return getProjectName().equals(e.getProjectName())
245246
&& getPhone().equals(e.getPhone())
246247
&& getEmail().equals(e.getEmail())
247-
&& getAddress().equals(e.getAddress())
248+
&& getProjectDescription().equals(e.getProjectDescription())
248249
&& getTags().equals(e.getTags())
249250
&& getTasks().equals(e.getTasks());
250251
}

0 commit comments

Comments
 (0)