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

New index.js (tiny JS) for OOP Exercise #342

Merged
merged 7 commits into from
Oct 9, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix bug with wrong name variable
  • Loading branch information
Levi123 committed Sep 21, 2022
commit 59760b42e924215ec0a6e975c94626aaf90a05be
12 changes: 10 additions & 2 deletions submissions/Levi123/oop-exercise/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
// class Animal {
// constructor (species, name, gender){
// this.species = species;
// this.name = name;
// this.gender = gender;
// }
// }
Copy link
Member

Choose a reason for hiding this comment

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

Don't keep comments in production code.
Exception: comments that explain reasons behind implementation peculiarities, that cannot be understood from the code itself (e.g. we cache data because server is down often and we want users to have some data anyways)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


class Entity {
Copy link
Member

Choose a reason for hiding this comment

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

entity is a generic term. Business domain and task requirements are a good source of naming ideas. Name should describe what entity it represents at a given level of abstraction - dog, cat, human, mammal, herbivore - in the given business domain.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

constructor (name, species, gender, saying){
this.name = name;
Expand All @@ -24,7 +32,7 @@ class Human extends Entity {
}

getProps (){
return super.getProp().concat([this.legs, this.hands])
return super.getProps().concat([this.legs, this.hands])
}
}

Expand All @@ -41,7 +49,7 @@ class Animal extends Entity {
}

getProps (){
return super.getProp().concat([this.paws])
return super.getProps().concat([this.paws])
}
}

Expand Down