-
Notifications
You must be signed in to change notification settings - Fork 0
fix Nick's comments to PR#7 #8
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
Conversation
elektronik2k5
left a comment
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.
Getting better
.eslintignore
Outdated
| dist | ||
| node_modules/ | ||
| dist/ | ||
| app/utils/BFS.js No newline at end of file |
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.
Remove. Replace with a comment inside the file itself.
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.
done
.eslintrc.js
Outdated
| objects: "always", | ||
| imports: "always", | ||
| exports: "always", | ||
| functions: "always-multiline" |
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.
Trailing comma? If your conf is JS, you should lint it too :)
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.
done
| <button { ...buttonProps }> | ||
| {text} | ||
| </button> | ||
| <button { ...buttonProps } /> |
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.
Now that it's a single line expression, drop the parents: return <button {...buttonProps} />
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.
done.
now, this section looks not very clear to my eyes at the moment. I mean, this structure of a div containing a relatively long map() inside of it.
I was thinking about taking out the function inside the map and putting it prior to the component's return.
you'll see it in the next commit. let me know what you think
app/components/Cell/Cell.js
Outdated
| pathEndingPoint, | ||
| } = state; | ||
| }, | ||
| cellIndex: { x, y, }, |
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 actually "index". Coordinates?
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.
done
| const isGoButtonDisabled = (locationOfStart, locationOfEnd) => ( | ||
| !isStartOrEndButtonDisabled(locationOfStart) || !isStartOrEndButtonDisabled(locationOfEnd) | ||
| ); | ||
| const getButtonClasses = isButtonPressed => `btn${isButtonPressed ? ' pressed' : ''}`; |
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.
OK, time for you to look into BEM naming. Don't necessarily use BEM, but learn about it and it's ideas and it will help you reason better about CSS/HTML class names.
|
|
||
| export default function Instructions({ state, }) { | ||
| function buildInstructionArray(appState) { | ||
| function createInstructionArray(appState) { |
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.
Plural "Instructions"
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.
done
| `Press on the "${buttonText}" button in order to go back to toggle mode` | ||
| ); | ||
| const setReferencePoint = buttonText => ( | ||
| const getReferencePoint = buttonText => ( |
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.
The line above ends with "Text", but this one doesn't. Be consistent. Decide how to name all similar parts and follow your decision.
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.
done.
Thought adding the word Text at the end of the variables below.
Then felt it would be a useless repetition.
Now, if I could put them all inside an object called instructions, but then I would destructure it and all the magic of using instructions['toggleTiles'] would go away. Is there sort of a middle ground?
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.
instructionTexts?
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.
But what about the retrieval of the strings? Wouldn't it be problematic with the DRY principle that I would use instructionTexts several times?
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.
Destructure it?
| instructionList.push(gameInstructions.goToChooseEndMode); | ||
| instructionList.push(goToChooseEndMode); | ||
| } | ||
| if (pathStartingPoint.length !== 0 && pathEndingPoint.length !== 0) { |
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.
DRY all .length === 0 into named consts. It will make it much more readable too. The code will say what, not how.
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.
done
|
|
||
| export default function Instructions({ state, }) { | ||
| function buildInstructionArray(appState) { | ||
| function createInstructionArray(appState) { |
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.
"Array" is an implementation detail. The caller shouldn't know it.
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.
done
| instructionList.push(gameInstructions.chooseReferencePoint); | ||
| instructionList.push(gameInstructions.goBackToToggleTileMode); | ||
| instructionList.push(chooseReferencePoint); | ||
| instructionList.push(goBackToToggleTileMode); |
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.
All these pushes can be DRYed and made readable: const addInstruction = instructionList.push. You may need to use bind too though: const addInstruction = instructionList.push.bind(instructionList)
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.
done
| const style = { | ||
| height: `${100 / buttons.length}%`, | ||
| }; | ||
| function createButton(buttonObject, index) { |
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.
Function returns a react component, so it should adhere to the naming convention: start with a Capital and not a verb. I know it's confusing, since it is also a function. But in JS most things are functions, and the function naming convention is a good baseline, which has exceptions for some cases. Some of these exceptions are in plain JS, others are for frameworks.
Examples:
- Before ES2015, classes were functions, so
function Animal(){}is a thing, as long as that's a class. - Factories (which return instances of different classes), are also functions and start with a Capital:
function Vehicle(), which can return a Car or Boat or Spaceship. - React stateless components :)
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.
so in this specific case Button() would make sense?
would it also require moving it to a separate file..? (cause then I suspect that Button() would be a bit too general)
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.
Yes, if inside the file, you can use Button. I'd call it Some Button and extract to a new file. GroupButton? AppButton?
If generic, Button is good. If specific, should be "SomeSpecificButton".
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.
done
elektronik2k5
left a comment
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 think this is enough changes for this PR :)
Start making more focused changes in feature branches now.
No description provided.