Giter Club home page Giter Club logo

connect_4_tdd's Introduction

connect_4_TDD

This is my first attempt at TDD. This game seems pretty doable normally, however TDD is new to me so I feel the challenge here will be in using RSPEC to test for the things I need to do.

PSEUDOCODE/BRAINSTORMING

First of all I need to make a board, a connect 4 board is 7 units wide and 6 units high (7 x 6 grid, 42 spaces)

-What is the best way to represent this board? Possibly a 2D array.

-What data do I have to know about every spot? what color the spot is, red, yellow or unclaimed and it needs to know where it is located, coordinates.

-How do I represent the board in terminal and update it? draw it with | and --- and so on. I probably need to write a loop that will do it as many times as I need to represent the board, but since it has to have an X and Y axis I need to figure that out too.

Secondly I need to make a player class which has the information of player_name and color

Finally I need to create the game logic.

-First thing for game logic what instance variables do I need? Player1 Player2 board Turn

-Second, I need to write a method that places a piece -select a column(1-7) -column is = to board.grid[0-6], therefore write a function that takes the numbers 1-7 and selects the column. -first write a function that checks if the number is valid -puts a piece at the bottom of the column if the bottom of the column is open

After this I switched to pen and paper to help visualize my board and think through some problems.

CONCLUSIONS: Writing tests really helped to speed up some aspects of the debugging but at the same time the initial hump was difficult to get over. I still need more practice with mocks, stubs, and doubles but i'll be continuing to use these in every project going forward from here so i'll be getting used to them that way.

Having a test suite really did help me to feel more secure when I'm just randomly changing values in my program and it saved a ton of time when I wanted to test a small change that I would have to work through my problem manually to verify.

However, I do feel that TDD itself sometimes felt like a drag on my time. When I was writing really simple methods I felt that writing the tests took longer than actually writing out the method.

All and all, this feels like a big upgrade to my skills are a coder and I'm looking forward to seeing how this changes the way I think about future projects.

connect_4_tdd's People

Contributors

justinkim2015 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.