-
-
Notifications
You must be signed in to change notification settings - Fork 184
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
tiny world pre-OOP #618
tiny world pre-OOP #618
Conversation
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 basic requirements from the original task. Universal recommendations:
By the way, you may proceed to the next task before this one is reviewed and merged. Sincerely yours, |
@YuraZagor please provide the link on the demo page in the first message. |
Done. I already did the OOP version of this in old repo, so had to create a new repo for this one |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YuraZagor double-check yoursefl against all requirements linked in the bot's message.
Also make sure to do whatever bot asks to do.
self-check done, code changed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YuraZagor the code is not DRY enough.
See the item 3 on the list posted by bot.
Simplified readability of the printing message with destructuring, although not sure was it what was needed. Also, had to change from forEach to simple for ... in |
Please copy the entire item 3 from the requirements here. |
Code is DRY, which means that whenever you see a pattern in your code it should be optimized. Examples: |
So the repeating part in your long string is |
const printArr = [species, name, gender, legs ? legs : paws, hands ? hands : tail, saying, friend] | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not .join
in this line? (not a rhetoric question)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also textToPrint
and printArr
are quite generic.
What would you call concepts this variables represent in the real world?
E.g. inhabitants are technically objects, but we still give variables that represent them names that are connected with the business domain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not .join() because we have conditions (ternary) and they would not be processed if stringified
As per the namings... inhabitantRepresentation and inhabitantRepresentationArr could be less generic I believe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inhabitantRepresentation sounds just right for a string data type.
If its content is a list of something then it would be probably inhabitantProperties. Note the "-s" at the end, this way we denote that a variable contains multiple things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this logic, thanks
let textToPrint = `${species}; ${name}; ${gender}; ${legs ? legs : paws}; ${hands ? hands : tail}; ${saying}; ${friend}`; | ||
const printArr = [species, name, gender, legs ? legs : paws, hands ? hands : tail, saying, friend] | ||
|
||
print(printArr.join('; '),'div') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re naming: imagine this line of code is 1000's lines of code away from the fragment where it's been formed, probably, even in a different file.
As a human peer developer I want to read what exactly this variable represents.
Code is written for other people. Computers are OK with low-level assembly codes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got it, thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YuraZagor please test the code and fix bugs
Sorry for wasting your time with broken code, re-wrote the erased ending. Now it seems running ok |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@YuraZagor great job!
For the OOP Exercise task, note that OOP helps to avoid "workarounds" like legs ? legs : paws, hands ? hands : tail
by designing classes so that every class handles its own properties without much care about what other classes do.
tiny world pre-OOP
Demo |
Code base
The code is submitted in a dedicated feature branch.
Only code files are submitted.
Please, review.