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

JS OOP Exercise task #454

Merged
merged 2 commits into from
Oct 9, 2022
Merged

JS OOP Exercise task #454

merged 2 commits into from
Oct 9, 2022

Conversation

franchukv
Copy link
Contributor

JS OOP Exercise

Demo | Code base

The code is submitted in a dedicated feature branch.

Only code files are submitted.

Please, review.

@github-actions
Copy link

github-actions bot commented Sep 6, 2022

Hey!

Congratulations on your PR! 😎😎😎

Let's do some self-checks to fix most common issues and to make some improvements to the code before reviewers put their hands on the code.

Go through the requirements/most common mistakes linked below and fix the code as appropriate.

If you have any questions to requirements/common mistakes feel free asking them here or in Students' chat.

When you genuinely believe you are done put a comment stating that you have completed self-checks and fixed code accordingly.

Also, be aware, that if you would silently ignore this recommendation, a mentor can think that you are still working on fixes. And your PR will not be reviewed. 😒

Please, make sure that your code follows the requirements based on the most common mistakes as well as requirements from the original task.

Universal recommendations:

  • Make sure your code follows General Requirements
  • Use common sense or seek for an advice whenever requirements look ambiguous or unclear.

By the way, you may proceed to the next task before this one is reviewed and merged.

Sincerely yours,
Submissions Kottachecker 😺

@franchukv
Copy link
Contributor Author

Self-checks done.

@OleksiyRudenko OleksiyRudenko added the self-check-done Student confirmed that self-checks against requirements/common-mistakes are done label Sep 20, 2022
Copy link
Member

@OleksiyRudenko OleksiyRudenko left a comment

Choose a reason for hiding this comment

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

@franchukv handling properties looks quite inconsistent.
Please review your code and improve it.

super(species, gender, name, status, saying, friends);
this.hands = 2;
this.feets = 2;
this.properties = [...this.properties, 'hands', 'feets', 'saying'];
Copy link
Member

Choose a reason for hiding this comment

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

A subclass shouldn't handle any properties owned by a super class.

Comment on lines 80 to 84
man.objToString(),
woman.objToString(woman.toMakeFriends()),
dog.objToString(dog.toMakeFriends()),
cat.objToString(cat.toMakeFriends()),
catwoman.objToString(catwoman.toMakeFriends()),
Copy link
Member

Choose a reason for hiding this comment

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

What construction object.objToString(obj.toMakeFriends()) does?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This construction was needed to save the order of properties when we print them, I rewrote code, please review new version

@OleksiyRudenko OleksiyRudenko self-assigned this Sep 20, 2022
Copy link
Member

@OleksiyRudenko OleksiyRudenko left a comment

Choose a reason for hiding this comment

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

@franchukv well done!

super('human', gender, name, status, saying, friends);
this.legs = 2;
this.hands = 2;
this.properties = [...this.properties, 'hands', 'legs'];
Copy link
Member

Choose a reason for hiding this comment

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

You should avoid handling base class' props directly.

}

inhabinantPropetriesToString() {
return this.properties.map((property) => this[property]).join('; ');
Copy link
Member

Choose a reason for hiding this comment

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

You should let child classes handle their own properties end-to-end.
Why that? Encapsulation.
Why encapsulation is important? Otherwise any change to any class properties forces us to change code in other classes. This leads to errors.

@OleksiyRudenko OleksiyRudenko merged commit 9454130 into kottans:main Oct 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
self-check-done Student confirmed that self-checks against requirements/common-mistakes are done Stage0.1 task-TJSW-OOP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants