Skip to content

Conversation

@OriLev
Copy link
Owner

@OriLev OriLev commented Jan 27, 2018

No description provided.

Copy link
Collaborator

@elektronik2k5 elektronik2k5 left a 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
Copy link
Collaborator

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.

Copy link
Owner Author

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"
Copy link
Collaborator

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 :)

Copy link
Owner Author

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 } />
Copy link
Collaborator

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} />

Copy link
Owner Author

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

pathEndingPoint,
} = state;
},
cellIndex: { x, y, },
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not actually "index". Coordinates?

Copy link
Owner Author

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' : ''}`;
Copy link
Collaborator

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) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Plural "Instructions"

Copy link
Owner Author

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 => (
Copy link
Collaborator

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.

Copy link
Owner Author

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?

Copy link
Collaborator

Choose a reason for hiding this comment

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

instructionTexts?

Copy link
Owner Author

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?

Copy link
Collaborator

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) {
Copy link
Collaborator

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.

Copy link
Owner Author

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) {
Copy link
Collaborator

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.

Copy link
Owner Author

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);
Copy link
Collaborator

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)

Copy link
Owner Author

Choose a reason for hiding this comment

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

done

@OriLev OriLev requested review from elektronik2k5 and removed request for elektronik2k5 February 1, 2018 16:13
const style = {
height: `${100 / buttons.length}%`,
};
function createButton(buttonObject, index) {
Copy link
Collaborator

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 :)

Copy link
Owner Author

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)

Copy link
Collaborator

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".

Copy link
Owner Author

Choose a reason for hiding this comment

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

done

Copy link
Collaborator

@elektronik2k5 elektronik2k5 left a 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.

@OriLev OriLev merged commit c5e4335 into master Feb 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants