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

[W6.2b][T16-2] Perry Wang #131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

perrythewang
Copy link

Added polymorphism to Command class

Copy link

@stephlewyh stephlewyh left a comment

Choose a reason for hiding this comment

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

You have not updated your JUnit tests.

Please note that going forward you need to update the tests as well when you make any behaviour changes.

@@ -15,6 +15,7 @@
protected AddressBook addressBook;
protected List<? extends ReadOnlyPerson> relevantPersons;
private int targetIndex = -1;
protected boolean mutatesData;

Choose a reason for hiding this comment

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

this variable is not used anywhere in your implementation. you may wish to omit this.

@@ -26,6 +27,10 @@ public Command(int targetIndex) {
protected Command() {
}

public boolean isMutating() {

Choose a reason for hiding this comment

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

Having a default implementation for isMutating() in the parent class is good as it reduces the amount of code. However, using an arbitrary default return value (like true) would reduce code understandability - as its subclasses implementations are returning false. Instead, you could declare isMutating() as an abstract method with no method body.

@@ -16,4 +16,8 @@ public CommandResult execute() {
return new CommandResult(MESSAGE_EXIT_ACKNOWEDGEMENT);
}

@Override
public boolean isMutating() {

Choose a reason for hiding this comment

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

Remember to update your method with header comments as your overriden method has a different behaviour from the parent class implementation. e.g. Returns if true if class mutates data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants