Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
seedu.address -> housekeeping.hub
  • Loading branch information
LimZiJia committed Apr 5, 2024
1 parent d273174 commit 786e9e2
Show file tree
Hide file tree
Showing 185 changed files with 1,167 additions and 1,340 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
id 'jacoco'
}

mainClassName = 'seedu.address.Main'
mainClassName = 'housekeeping.hub.Main'

sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
Expand Down
91 changes: 6 additions & 85 deletions docs/DeveloperGuide.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,104 +153,22 @@ The `Storage` component,

### Common classes

Classes used by multiple components are in the `seedu.addressbook.commons` package.
Classes used by multiple components are in the `housekeeping.addressbook.commons` package.

--------------------------------------------------------------------------------------------------------------------

## **Implementation**

This section describes some noteworthy details on how certain features are implemented.

### \[Completed\] Sorting cleints by predicted next cleaning date
### \[Completed\] Generating leads for housekeeping services

In an admin operator's job there is a use case where they need to sort the clients by the predicted next cleaning date.
This is useful for the operator to remind the clients to book their next service soon. We have stored this housekeeping information
in `HousekeepingDetails` which also supports some other use cases such as the client does not want to be called or would
prefer to be called on a later date.

#### How the feature is implemented

* `VersionedAddressBook#commit()` — Saves the current address book state in its history.
* `VersionedAddressBook#undo()` — Restores the previous address book state from its history.
* `VersionedAddressBook#redo()` — Restores a previously undone address book state from its history.

These operations are exposed in the `Model` interface as `Model#commitAddressBook()`, `Model#undoAddressBook()` and `Model#redoAddressBook()` respectively.

Given below is an example usage scenario and how the undo/redo mechanism behaves at each step.

Step 1. The user launches the application for the first time. The `VersionedAddressBook` will be initialized with the initial address book state, and the `currentStatePointer` pointing to that single address book state.

![UndoRedoState0](images/UndoRedoState0.png)

Step 2. The user executes `delete 5` command to delete the 5th person in the address book. The `delete` command calls `Model#commitAddressBook()`, causing the modified state of the address book after the `delete 5` command executes to be saved in the `addressBookStateList`, and the `currentStatePointer` is shifted to the newly inserted address book state.

![UndoRedoState1](images/UndoRedoState1.png)

Step 3. The user executes `add n/David …​` to add a new person. The `add` command also calls `Model#commitAddressBook()`, causing another modified address book state to be saved into the `addressBookStateList`.

![UndoRedoState2](images/UndoRedoState2.png)

<div markdown="span" class="alert alert-info">:information_source: **Note:** If a command fails its execution, it will not call `Model#commitAddressBook()`, so the address book state will not be saved into the `addressBookStateList`.

</div>

Step 4. The user now decides that adding the person was a mistake, and decides to undo that action by executing the `undo` command. The `undo` command will call `Model#undoAddressBook()`, which will shift the `currentStatePointer` once to the left, pointing it to the previous address book state, and restores the address book to that state.

![UndoRedoState3](images/UndoRedoState3.png)

<div markdown="span" class="alert alert-info">:information_source: **Note:** If the `currentStatePointer` is at index 0, pointing to the initial AddressBook state, then there are no previous AddressBook states to restore. The `undo` command uses `Model#canUndoAddressBook()` to check if this is the case. If so, it will return an error to the user rather
than attempting to perform the undo.

</div>

The following sequence diagram shows how an undo operation goes through the `Logic` component:

![UndoSequenceDiagram](images/UndoSequenceDiagram-Logic.png)

<div markdown="span" class="alert alert-info">:information_source: **Note:** The lifeline for `UndoCommand` should end at the destroy marker (X) but due to a limitation of PlantUML, the lifeline reaches the end of diagram.

</div>

Similarly, how an undo operation goes through the `Model` component is shown below:

![UndoSequenceDiagram](images/UndoSequenceDiagram-Model.png)

The `redo` command does the opposite — it calls `Model#redoAddressBook()`, which shifts the `currentStatePointer` once to the right, pointing to the previously undone state, and restores the address book to that state.

<div markdown="span" class="alert alert-info">:information_source: **Note:** If the `currentStatePointer` is at index `addressBookStateList.size() - 1`, pointing to the latest address book state, then there are no undone AddressBook states to restore. The `redo` command uses `Model#canRedoAddressBook()` to check if this is the case. If so, it will return an error to the user rather than attempting to perform the redo.

</div>

Step 5. The user then decides to execute the command `list`. Commands that do not modify the address book, such as `list`, will usually not call `Model#commitAddressBook()`, `Model#undoAddressBook()` or `Model#redoAddressBook()`. Thus, the `addressBookStateList` remains unchanged.

![UndoRedoState4](images/UndoRedoState4.png)

Step 6. The user executes `clear`, which calls `Model#commitAddressBook()`. Since the `currentStatePointer` is not pointing at the end of the `addressBookStateList`, all address book states after the `currentStatePointer` will be purged. Reason: It no longer makes sense to redo the `add n/David …​` command. This is the behavior that most modern desktop applications follow.

![UndoRedoState5](images/UndoRedoState5.png)

The following activity diagram summarizes what happens when a user executes a new command:

<img src="images/CommitActivityDiagram.png" width="250" />

#### Design considerations:

**Aspect: How undo & redo executes:**

* **Alternative 1 (current choice):** Saves the entire address book.
* Pros: Easy to implement.
* Cons: May have performance issues in terms of memory usage.

* **Alternative 2:** Individual command knows how to undo/redo by
itself.
* Pros: Will use less memory (e.g. for `delete`, just save the person being deleted).
* Cons: We must ensure that the implementation of each individual command are correct.

_{more aspects and alternatives to be added}_

### \[Proposed\] Generating leads for housekeeping services

#### Proposed Implementation
#### How it is implemented
We assume clients who do not have `HousekeepingDetails` do not want to be disturbed by the housekeeping company.
Therefore, the client list should be first filtered by `Client.hasHousekeepingDetais()` then sorted by `HousekeepingDetails`.
We will also not show clients who have their predicted next housekeeping date that is after the current date.
Expand All @@ -261,6 +179,9 @@ The `compareTo()` method calls the `HousekeepingDetails`'s `compareTo()` method
The `compareTo()` method in `HousekeepingDetails` uses the `getNextHousekeepingDate()` method which is calculated by
`lastHousekeepingDate.plus(preferredInterval)`.

`ClientComprator` is then used by `FXCollections.sort()` to sort the list of clients. `ClientComparator` compares `Client`s
using their `compareTo()` method.

We will also store `bookingDate` if the `Client` already made a booking. This is convenient for the admin to know and prevent
calling the client when it is not needed. Furthermore, `deferment` is also stored to know if the client wants to defer the
reminder to a later date.
Expand Down
2 changes: 1 addition & 1 deletion docs/SettingUp.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ If you plan to use Intellij IDEA (highly recommended):
1. **Import the project as a Gradle project**: Follow the guide [_[se-edu/guides] IDEA: Importing a Gradle project_](https://se-education.org/guides/tutorials/intellijImportGradleProject.html) to import the project into IDEA.<br>
:exclamation: Note: Importing a Gradle project is slightly different from importing a normal Java project.
1. **Verify the setup**:
1. Run the `seedu.address.Main` and try a few commands.
1. Run the `housekeeping.hub.Main` and try a few commands.
1. [Run the tests](Testing.md) to ensure they all pass.

--------------------------------------------------------------------------------------------------------------------
Expand Down
6 changes: 3 additions & 3 deletions docs/Testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ There are two ways to run tests.
This project has three types of tests:

1. *Unit tests* targeting the lowest level methods/classes.<br>
e.g. `seedu.address.commons.StringUtilTest`
e.g. `housekeeping.hub.commons.StringUtilTest`
1. *Integration tests* that are checking the integration of multiple code units (those code units are assumed to be working).<br>
e.g. `seedu.address.storage.StorageManagerTest`
e.g. `housekeeping.hub.storage.StorageManagerTest`
1. Hybrids of unit and integration tests. These test are checking multiple code units as well as how the are connected together.<br>
e.g. `seedu.address.logic.LogicManagerTest`
e.g. `housekeeping.hub.logic.LogicManagerTest`
14 changes: 7 additions & 7 deletions docs/tutorials/AddRemark.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ We’ll assume that you have already set up the development environment as outli

Looking in the `logic.command` package, you will notice that each existing command have their own class. All the commands inherit from the abstract class `Command` which means that they must override `execute()`. Each `Command` returns an instance of `CommandResult` upon success and `CommandResult#feedbackToUser` is printed to the `ResultDisplay`.

Let’s start by creating a new `RemarkCommand` class in the `src/main/java/seedu/address/logic/command` directory.
Let’s start by creating a new `RemarkCommand` class in the `src/main/java/housekeeping/address/logic/command` directory.

For now, let’s keep `RemarkCommand` as simple as possible and print some output. We accomplish that by returning a `CommandResult` with an accompanying message.

**`RemarkCommand.java`:**

``` java
package seedu.address.logic.commands;
package housekeeping.hub.logic.commands;

import seedu.address.model.Model;
import housekeeping.hub.model.Model;

/**
* Changes the remark of an existing person in the address book.
Expand Down Expand Up @@ -91,7 +91,7 @@ Let’s change `RemarkCommand` to parse input from the user.
We start by modifying the constructor of `RemarkCommand` to accept an `Index` and a `String`. While we are at it, let’s change the error message to echo the values. While this is not a replacement for tests, it is an obvious way to tell if our code is functioning as intended.

``` java
import static seedu.address.commons.util.CollectionUtil.requireAllNonNull;
import static housekeeping.hub.commons.util.CollectionUtil.requireAllNonNull;
//...
public class RemarkCommand extends Command {
//...
Expand Down Expand Up @@ -140,7 +140,7 @@ Your code should look something like [this](https://github.com/se-edu/addressboo

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

Create a `RemarkCommandParser` class in the `seedu.address.logic.parser` package. The class must extend the `Parser` interface.
Create a `RemarkCommandParser` class in the `housekeeping.hub.logic.parser` package. The class must extend the `Parser` interface.

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

Expand Down Expand Up @@ -227,7 +227,7 @@ Now that we have all the information that we need, let’s lay the groundwork fo

### Add a new `Remark` class

Create a new `Remark` in `seedu.address.model.person`. Since a `Remark` is a field that is similar to `Address`, we can reuse a significant bit of code.
Create a new `Remark` in `housekeeping.hub.model.person`. Since a `Remark` is a field that is similar to `Address`, we can reuse a significant bit of code.

A copy-paste and search-replace later, you should have something like [this](https://github.com/se-edu/addressbook-level3/commit/4516e099699baa9e2d51801bd26f016d812dedcc#diff-41bb13c581e280c686198251ad6cc337cd5e27032772f06ed9bf7f1440995ece). Note how `Remark` has no constrains and thus does not require input
validation.
Expand All @@ -240,7 +240,7 @@ Let’s change `RemarkCommand` and `RemarkCommandParser` to use the new `Remark`

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

Simply add the following to [`seedu.address.ui.PersonCard`](https://github.com/se-edu/addressbook-level3/commit/850b78879582f38accb05dd20c245963c65ea599#diff-639834f1e05afe2276a86372adf0fe5f69314642c2d93cfa543d614ce5a76688).
Simply add the following to [`housekeeping.hub.ui.PersonCard`](https://github.com/se-edu/addressbook-level3/commit/850b78879582f38accb05dd20c245963c65ea599#diff-639834f1e05afe2276a86372adf0fe5f69314642c2d93cfa543d614ce5a76688).

**`PersonCard.java`:**

Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/RemovingFields.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,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.person.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 `Person` is actually an instance of the `housekeeping.hub.model.person.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`

![Usages detected](../images/remove/UnsafeDelete.png)
Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/TracingCode.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ In our case, we would want to begin the tracing at the very point where the App

<img src="../images/ArchitectureSequenceDiagram.png" width="550" />

According to the sequence diagram you saw earlier (and repeated above for reference), the `UI` component yields control to the `Logic` component through a method named `execute`. Searching through the code base for an `execute()` method that belongs to the `Logic` component yields a promising candidate in `seedu.address.logic.Logic`.
According to the sequence diagram you saw earlier (and repeated above for reference), the `UI` component yields control to the `Logic` component through a method named `execute`. Searching through the code base for an `execute()` method that belongs to the `Logic` component yields a promising candidate in `housekeeping.hub.logic.Logic`.

<img src="../images/tracing/searchResultsForExecuteMethod.png" />

Expand All @@ -48,7 +48,7 @@ According to the sequence diagram you saw earlier (and repeated above for refere
:bulb: **Intellij Tip:** The ['**Search Everywhere**' feature](https://www.jetbrains.com/help/idea/searching-everywhere.html) can be used here. In particular, the '**Find Symbol**' ('Symbol' here refers to methods, variables, classes etc.) variant of that feature is quite useful here as we are looking for a _method_ named `execute`, not simply the text `execute`.
</div>

A quick look at the `seedu.address.logic.Logic` (an extract given below) confirms that this indeed might be what we’re looking for.
A quick look at the `housekeeping.hub.logic.Logic` (an extract given below) confirms that this indeed might be what we’re looking for.

```java
public interface Logic {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.address;
package housekeeping.hub;

import java.nio.file.Path;
import java.nio.file.Paths;
Expand All @@ -7,9 +7,9 @@
import java.util.logging.Logger;

import javafx.application.Application;
import seedu.address.commons.core.LogsCenter;
import seedu.address.commons.util.FileUtil;
import seedu.address.commons.util.ToStringBuilder;
import housekeeping.hub.commons.core.LogsCenter;
import housekeeping.hub.commons.util.FileUtil;
import housekeeping.hub.commons.util.ToStringBuilder;

/**
* Represents the parsed command-line parameters given to the application.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package seedu.address;
package housekeeping.hub;

import java.util.logging.Logger;

import javafx.application.Application;
import seedu.address.commons.core.LogsCenter;
import housekeeping.hub.commons.core.LogsCenter;

/**
* The main entry point to the application.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.address;
package housekeeping.hub;

import java.io.IOException;
import java.nio.file.Path;
Expand All @@ -7,29 +7,29 @@

import javafx.application.Application;
import javafx.stage.Stage;
import seedu.address.commons.core.Config;
import seedu.address.commons.core.LogsCenter;
import seedu.address.commons.core.Version;
import seedu.address.commons.exceptions.DataLoadingException;
import seedu.address.commons.util.ConfigUtil;
import seedu.address.commons.util.StringUtil;
import seedu.address.logic.Logic;
import seedu.address.logic.LogicManager;
import seedu.address.model.AddressBook;
import seedu.address.model.Model;
import seedu.address.model.ModelManager;
import seedu.address.model.ReadOnlyAddressBook;
import seedu.address.model.ReadOnlyUserPrefs;
import seedu.address.model.UserPrefs;
import seedu.address.model.util.SampleDataUtil;
import seedu.address.storage.AddressBookStorage;
import seedu.address.storage.JsonAddressBookStorage;
import seedu.address.storage.JsonUserPrefsStorage;
import seedu.address.storage.Storage;
import seedu.address.storage.StorageManager;
import seedu.address.storage.UserPrefsStorage;
import seedu.address.ui.Ui;
import seedu.address.ui.UiManager;
import housekeeping.hub.commons.core.Config;
import housekeeping.hub.commons.core.LogsCenter;
import housekeeping.hub.commons.core.Version;
import housekeeping.hub.commons.exceptions.DataLoadingException;
import housekeeping.hub.commons.util.ConfigUtil;
import housekeeping.hub.commons.util.StringUtil;
import housekeeping.hub.logic.Logic;
import housekeeping.hub.logic.LogicManager;
import housekeeping.hub.model.AddressBook;
import housekeeping.hub.model.Model;
import housekeeping.hub.model.ModelManager;
import housekeeping.hub.model.ReadOnlyAddressBook;
import housekeeping.hub.model.ReadOnlyUserPrefs;
import housekeeping.hub.model.UserPrefs;
import housekeeping.hub.model.util.SampleDataUtil;
import housekeeping.hub.storage.AddressBookStorage;
import housekeeping.hub.storage.JsonAddressBookStorage;
import housekeeping.hub.storage.JsonUserPrefsStorage;
import housekeeping.hub.storage.Storage;
import housekeeping.hub.storage.StorageManager;
import housekeeping.hub.storage.UserPrefsStorage;
import housekeeping.hub.ui.Ui;
import housekeeping.hub.ui.UiManager;

/**
* Runs the application.
Expand Down Expand Up @@ -68,9 +68,9 @@ public void init() throws Exception {
}

/**
* Returns a {@code ModelManager} with the data from {@code storage}'s address book and {@code userPrefs}. <br>
* The data from the sample address book will be used instead if {@code storage}'s address book is not found,
* or an empty address book will be used instead if errors occur when reading {@code storage}'s address book.
* Returns a {@code ModelManager} with the data from {@code storage}'s hub book and {@code userPrefs}. <br>
* The data from the sample hub book will be used instead if {@code storage}'s hub book is not found,
* or an empty hub book will be used instead if errors occur when reading {@code storage}'s hub book.
*/
private Model initModelManager(Storage storage, ReadOnlyUserPrefs userPrefs) {
logger.info("Using data file : " + storage.getAddressBookFilePath());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package seedu.address.commons.core;
package housekeeping.hub.commons.core;

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Objects;
import java.util.logging.Level;

import seedu.address.commons.util.ToStringBuilder;
import housekeeping.hub.commons.util.ToStringBuilder;

/**
* Config values used by the app
Expand Down
Loading

0 comments on commit 786e9e2

Please sign in to comment.