DEV Community

JesseNReynolds
JesseNReynolds

Posted on

My first project

When I signed up for Flatiron School, I started keeping a little idea log for apps to build. I opened that idea log up when it was time to plan my first project, and I grabbed one I thought would be fun and could be factored well into the project requirements. What I found surprising was how quickly my minimum viable product came together! Sure, it didn't check off all the boxes I wanted to, but it did what the app wants to do at it's heart.

From there it was a matter of adding features, refactoring things that are not best practices, improving the interface, streamlining the logic, etc.

What seemed a few weeks ago like it would be a big job seems easy now, at least in recollection. Of course there were moments of frustration; there were things that made me confused, things that I just could not get working for the longest time, but every time I checked something off my features wish-list, I got a nice hit of dopamine that made the whole process very enjoyable.

It's not perfect, it's not finished but it works, and I built it.

I learned some stuff, like using a while loop to control for answers to prompts that aren't understandable or would create problems down the line, instead of using recursion.

def filter_price
        complete = false

        while complete == false
            puts "Do you want to filter by price? (y/n)"
            answer = gets.chomp
            if answer.downcase == "y" || answer.downcase == "yes"
                puts "Restaurants are given price ranges from 1 to 4, where 4 is the highest."

                puts "Please enter a minimum price range from 1 to 4 (decimals NOT OK!)"
                min_price = gets.chomp.to_i

                puts "Please enter a maximum price range from 1 to 4(decimals NOT OK!)"
                max_price = gets.chomp.to_i

                complete = true

                if min_price > max_price 
                    puts "Please enter a maximum price range that is higher than or equal to your minimum price range."
                    complete = false
                end

            elsif answer.downcase == "n" || answer.downcase == "no"
                min_price = 1
                max_price = 4
                complete = true
            else
                puts "Sorry, I don't understand, please respond with y or n"
            end
        end
Enter fullscreen mode Exit fullscreen mode

I got more practice writing methods from scratch, passing data around, creating objects with that data, and iterating over the objects to actually do stuff with the data inside.

The jump from the JSON data that Yelp returned to properly instantiated data attached to objects created a fun challenge that I was able to solve with meta-programming to help improve scalability and compatibility in the future.


    def self.new_from_json(parsed_data)
        parsed_data["businesses"].each do |business|
            new_restaurant = Restaurants.new

            business.each do |key, value|
                new_restaurant.class.send(:attr_accessor, "#{key}")
                # creates attr_accessor for each key in the imported hash  
                new_restaurant.send("#{key}=", value)
            end

            new_restaurant.save
        end
    end
Enter fullscreen mode Exit fullscreen mode

Overall, I think my favorite part of having the chance to do something like this, to build something that I wanted, see the finished product work, and even using it here and there in my daily life, is a familiar feeling in an odd way. I've long been an advocate in my personal life for productive hobbies like leatherworking, woodworking, sewing, or knitting. I think so often we live lives of abstract productivity, rarely seeing a product or process through from start to finish, and there's great empowerment in the manifestation of something from material and desire. The fact that that feeling of empowerment and achievement is present in developing code makes me feel more certain that I've made a choice in changing careers that will bring great satisfaction to my life; and I think that's really pretty cool.

Oldest comments (0)