General Guidelines to Approaching Problems

Hi, I am having trouble figuring out how I should approach a problem when I am unclear of where to even start. For example, I am on the temperature object problem for RSPEC Practice 4, and I feel lost. I started by looking at the spec and seeing what methods are called on which objects so I knew what methods I needed to define for each class. Then when it comes to filling in the method bodies, I really have no idea what each one should do, so I look at the solution for ideas. Even with the solution in front of me, I don’t understand what any of the methods are doing except for “ftoc”, “ctof” and the setter methods. I know it’s not beneficial to my learning to just copy the solution if I don’t understand it, so I’m wondering what to do next in this sort of situation to get to the point where I understand what the problems are asking of me.

Hi Amanda,

I remember that one was tricky because there are many ways that it could be done but only a couple that pass the rspec.
Based on what I’ve heard from all the coders I’ve talked to:

  1. an important part of coding is to persevere even when you don’t understand.
  • have faith that you will figure it out with enough attempts, and that the struggle is part of the learning process. Once you get it you will look back and see the problem with perfect clarity.
  1. go step by step
    -especially with rspec, passing one test at a time can make it easier to reach the solution compared to trying all of the problems at once.

  2. Assess what is needed
    -Carefully analyze the return value implied by the method name. “in_celsius” implies that something is being converted from Fahrenheit to Celsius.
    -Check what parameters are being passed in to the method. Does the method take an options hash? An options hash would mean that the values are not ordered and have to be accessed by keys.

I’m sure you’ll figure it out.
also, there’s nothing wrong with studying the solution if you can absorb the reasons it was done the way it was done!


Thank you for the advice, Luke! I did end up figuring this one out. The biggest strategy mistake I was making was looking at all the specs and writing a list of all the methods that I would need to define. Going step by step is definitely what I need to do. It is so much easier to start with spec one and write the first method needed, then move on, instead of getting overwhelmed by looking at the entire picture all at once. Doing much better now with this in mind!