Connect Four Review


Hey everyone!

I just completed the connect four TDD project. I was wondering if anyone would like to have a look at my project and give me some feedback. I struggled a lot with design decisions in this project (regarding OOP practices), and learning some aspects of rspec. I would also like to hear how some other people chose to solve this problem.

Coming from the knight’s travails project, I originally thought that I should use a graph to represent the connections between board spaces, in order to check the board for wins. However, I found that representing the board as a graph made it trickier to update and display the state of the board. Thus, I chose to represent the board state as an array of arrays (the columns of the board). I also thought it would make sense to store the coordinates of the connected spaces that could possibly win the game in a hash so that checking over them later was easier.

Ultimately I am happy with the decisions I made. Any feedback is appreciated, thanks.


Hey @learnsometing

It looks pretty good to me. There are always areas you can improve but there isn’t anything I can see there that could be considered a seriou issue.

Keep moving forward.


Sometimes you can implicitly return true/false values from the function without typing return true, return false

For example :

  def out_of_bounds?(col)
        if col < 0 || col > 6 
            return true
        return false

you can rewrite as

def out_of_bounds?(col)
    col < 0 || col > 6

and it should return the same thing


Thanks for the tip. Your improvement is definitely sexier. I’ll keep this in mind moving forward.


Sounds good to me. Thanks as always for the help and advice.