Published on 29 Jul 2020 by Dave Regg
As I work towards a new career, I have continuously followed different paths. Everytime I get stuck, I move onto the next video or the next tutorial or the next whatever, but I never persevere through my difficulties. Right now, I am having a difficult time on The Odin Project, specifically the Testing Javascript section of the Javascript course.
I have already worked through functional programming. I worked through DOM Manipulation. But now that they suggest a Battleship project, I don't know where to begin. Part of the reason is because I have no interest in building games. I want to build web applications with a backend and a beautiful design. But part of it is also the lack of guidance.
The reason I want to continue with the project is because I want to focus on the testing portion of TOP. I want to implement Jest with the project and focus on Test Driven Development. However, that's one of the problems- I don't know how to begin TDD, especially because, problem number two, I suck with Object Oriented Programming with Javascript. Some of the concept is lost on me, and then using tests with objects is adding a new layer of confusion.
So here I sit, staring at a blank canvas, unsure of where to begin. What can my solutions look like?
As every new programmer learns, a project should be planned and then worked through piece by piece. This means grabbing a paper and notepad and writing out what the objective of each Object. Maybe add some pseudocode, and think of how each Object will interact with one another.
What will a Gameboard Object look like? When a game boots up, two Gameboards will be built, one for each player. A gameboard
will be populated with ten ships
of various sizes. A user will interact with the opponent's gameboard
and either hit
or miss
a ship. Those coordinates
are then marked off as unable to be interacted with.
The Ship on the player's gameboard
will have a length
between one and five spaces. Each ship
will then populate an array, where the index can be hit
. If the length
of a ship
are all hit, then it isSunk
.
Finally, each game will involve two Players interacting. Player one will have a gameboard
with ten ships
, and Player two will have a separate gameboard
with ten ships
. Players will take turns
interacting with the opponent's gameboard
and guessing
available spaces. If the player hits
an opponent's ship
, or sinks
it, the gameboard
will checkForWinner
. Play will involve turns.
The Odin Project, freeCodeCamp, and other online communities have installed some great ways to interact with fellow students. These involve Forums, Slack and Discord, Twitter hashtags, and Reddit subreddits.
Often times, it can be intimidating to ask for help. When writing out a post in a forum or a message on Discord, a question with a lot of explanation can get wordy. Then you need to include code samples, which adds another layer.
This is why I often kick myself for never going to live meet ups where I can interact with programmers, get there feedback verbally, and show them the code on my laptop. It would be a lot easier to get some help when they are looking over my shoulder.
Instead of thinking of what-ifs, I could just take advantage of what is available to me. Look at all of these great resources! I could be interacting with people around the globe, and instead I'm getting intimidated because Joe-Shmoe might not like my wording. What's the worst that could happen? It could be completely ignored, and then I find my own solution elsewhere.
And give up.
Just kidding!
(Kind of...)
Yeah, just walking away from the project for a couple of hours and thinking about something else. Or think about the project. Something could potentially click.
For me, this has worked many times, especially with algorithms. I will get stuck on a Project Euler problem so I'll watch a TV show. In the middle of it, something will dawn on me, so I'll grab a paper and pad and right down what to do next.
Or something about programming will become clearer to me and I just need to write down some notes so I can remember to type about it on my blog later! 😀
Even as I type this blog post, I am actively getting ideas for the blank page, and now I know how to plan out what to program before I can attack those blank pages and build a successful application! I'm looking forward to continuing my project and learning more about Object Oriented Programming and Test Driven Development!