Dana-Gallo / Connect-Four-Project

Contains HTML, CSS, and JS for Unit 16 Connect Four Project
https://dana-gallo.github.io/Connect-Four-Project/
0 stars 0 forks source link

thoughts and opinions from tech club #1

Open VietThan opened 1 year ago

VietThan commented 1 year ago
Michael-Gayevsky commented 1 year ago

I think this is great! Keep up the good work! @Dana-Gallo

Potense commented 1 year ago

Your Connect Four code looks quite well-structured and readable. However, there are some areas where you can improve code clarity, maintainability, and documentation. Here are some suggestions:

  1. Add Comments: While your code already has comments, consider adding more comments to explain complex logic or functions that may not be immediately obvious to someone reading the code for the first time.

  2. Use Descriptive Variable Names: Variable names like y and x are fine for loop counters, but consider using more descriptive names in functions. For example, findSpotForCol could use columnIndex instead of x, and placeInTable could use rowIndex and columnIndex instead of y and x.

  3. Modularize Functions: Some of your functions are quite long. You can break them down into smaller, more focused functions to improve readability and maintainability. For example, you could create a function to check for a win condition, and another for checking for a tie game.

  4. Use Constants for Player Numbers: Instead of hardcoding player numbers (1 and 2) in various places, consider defining constants like PLAYER_1 and PLAYER_2 at the beginning of your code to make it more readable and avoid potential errors.

  5. Error Handling: Consider adding error handling or validation to handle unexpected scenarios, such as clicks on full columns.

  6. Separate Game Logic from Presentation: Although your code does a decent job of separating game logic from presentation (HTML), you can further improve this separation. You might consider moving the game logic into a separate module or class, making it easier to reuse and test.

  7. CSS Separation: If you have CSS styles for your game, consider separating them into a separate CSS file rather than adding styles directly to elements in JavaScript.

  8. Testing: Consider adding unit tests to verify the correctness of your game logic.