Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor commands #35

Merged

Conversation

yan-soon
Copy link

@yan-soon yan-soon commented Oct 5, 2020

Refactored Command, Parser and Storage packages.

Changes to Production Classes:

Name -> ModuleCode
Phone -> ModularCredits
Deleted Email and Address fields

Person -> Module

EditPersonDescriptor -> EditModuleDescriptor

AddressBookParser -> GradPadParser
AddressBookStorage -> GradPadStorage
JsonAdaptedPerson -> JsonAdaptedModule
JsonAddressBookStorage -> JsonGradPadStorage

Changes to Test Classes:

EditPersonDescriptorTest -> EditModuleDescriptorTest

AddressBookParserTest -> GradPadParserTest
JsonAdaptedPersonTest -> JsonAdaptedModuleTest
JsonAddressBookStorageTest -> JsonGradPadStorageTest
JsonSerializableAddressBookTest -> JsonSerializableGradPadTest

Changes to Test Util:

EditPersonDescriptorBuilder -> EditModuleDescriptorBuilder
AddressBookBuilder -> GradPadBuilder

Changes to test/data folders and files:

JsonAddressBookStorageTest -> JsonGradPadStorageTest (FOLDER)
invalidAndValidPersonAddressBook.json -> invalidAndValidModuleGradPad.json
invalidPersonAddressBook.json -> invalidModuleGradPad.json
notJsonFormatAddressBook -> notJsonFormatGradPad

JsonSerializableAddressBookTest -> JsonSerializableGradPadTest (FOLDER)
duplicatePersonAddressBook.json -> duplicateModuleGradPad.json
invalidPersonAddressBook.json -> invalidModuleGradPad.json
typicalPersonsAddressBook.json -> typicalModulesGradPad.json

Contents of the test data has also been changed from Person to Module

Notes

When refactoring, changed some names from the UI package (person -> module, name -> modulecode, etc).
Currently passes all tests from the Command and Parser packages and passes most of the tests from the Storage package (currently failing 3 tests)

@yan-soon yan-soon requested a review from a team October 5, 2020 18:02
@yan-soon yan-soon linked an issue Oct 5, 2020 that may be closed by this pull request
Copy link

@Silvernitro Silvernitro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review covers the rest of the production classes (I haven't reviewed the tests yet).

Also the getAddressBookFilePath method in the Logic interface/LogicManager class might have been missed out in the refactoring hehe but I couldn't leave a comment cos those lines weren't marked as diffs.

src/main/java/seedu/address/storage/JsonAdaptedModule.java Outdated Show resolved Hide resolved
Comment on lines +50 to +53
for (JsonAdaptedModule jsonAdaptedModule : modules) {
Module module = jsonAdaptedModule.toModelType();
if (gradPad.hasModule(module)) {
throw new IllegalValueException(MESSAGE_DUPLICATE_MODULE);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a suggestion/request for change, but I was just wondering why the original code does this redundant check here when it could just call gradPad's setModules fxn, which already uses UniqueModuleList to ensure all modules are unique.

I just put this comment here first in case we want to improve code quality next time.

Suggested change
for (JsonAdaptedModule jsonAdaptedModule : modules) {
Module module = jsonAdaptedModule.toModelType();
if (gradPad.hasModule(module)) {
throw new IllegalValueException(MESSAGE_DUPLICATE_MODULE);
List<Modules> gradPadModules = modules.stream().map(JsonAdaptedModule::toModelType).collect(Collectors.toList());
try {
gradpad.setModules(gradPadModules);
} catch (DuplicateModuleException ex) {
throw new IllegalValueException(MESSAGE_DUPLICATE_MODULE);
}

Copy link

@Silvernitro Silvernitro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the test classes and mostly looks great man; just a few nits!

Copy link

@shaokiat shaokiat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NICE ONE 👍

src/main/java/seedu/address/logic/Logic.java Outdated Show resolved Hide resolved
src/main/java/seedu/address/logic/commands/AddCommand.java Outdated Show resolved Hide resolved
src/test/java/seedu/address/testutil/ModuleUtil.java Outdated Show resolved Hide resolved
@shaokiat shaokiat added this to the v1.2 milestone Oct 6, 2020
@yan-soon
Copy link
Author

yan-soon commented Oct 6, 2020

Great find guys, I've edited accordingly to your comments. Thanks :)

Copy link

@Silvernitro Silvernitro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Steady brother 👍 Thanks for addressing all the comments 💯

@mhdsyfq77 mhdsyfq77 requested review from a team and removed request for a team October 7, 2020 10:08
@mhdsyfq77 mhdsyfq77 requested review from Silvernitro and removed request for Silvernitro October 7, 2020 10:08
@mhdsyfq77 mhdsyfq77 merged commit c7f0be1 into AY2021S1-CS2103T-T09-1:v1.2-refactor Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Refactor Commands, Parser and Storage Package
4 participants