P.F. This article was written on 07/December/2019
I'm bringing all of my old articles to Dev.to
The domain that I decided to work with, in my Sinatra project is RSS (Really Simple Syndication). I came across RSS when I wanted to subscribe to podcasts in the iTunes podcast app. I was intrigued by the RSS concept and found great RSS feed readers online like Feedly but thought that it would be fun to make my own RSS reader one day. Moving on, as I completed my Sinatra course work and now I had to make a portfolio project using my new skills of Sinatra, I decided to make an RSS feed reader.
RSS feed is provided by a website and is updated by the website periodically and it's just an XML file that we can access using the link that the website provides to you. You provide that link to your RSS reader application and it will load content from that XML file in the application. The RSS reader can also look for new updates from the website. This way you can keep tabs on multiple websites using a single application.
Languages and technologies I used
- SQLITE3 (Development, Test) & Postgre SQL (Production)
- SINATRA (Ruby Web Framework or Library)
- SimpleRSS (Library)
- ActiveRecord(Rails default Object Relational Mapper)
My app uses a ruby gem called SimpleRSS which can parse feed from the internet and provide you a nice and clean ruby object to play with the data of the RSS document that you provide to it using OPEN-URI which is a Ruby built-in method that makes HTTP requests programmatically.
I get all the data that I need through SimpleRSS and then I make a feed and its articles. I have three main classes in my domain.
A feed is a website's RSS feed instance. A feed can have many articles. FeedHandler handles all the logic required to get data from the RSS document and creating articles for feeds.
You can look at the app here
Feel free to check out both the source code and the app.
This was a brief intro of my project but today I really want to talk about what I have actually learned by building this app and that is the most important thing to understand by building these projects, I believe.
I had made a Sinatra project before as well and moved on to Ruby on Rails. I made substantial progress in Rails and was almost done with Rails but as I approached the end of the Ruby on Rails coursework. I realized something. Do I want to just keep programming and keep moving forward or I should take a step back and realize what I have learned so far? What I realized that even after solving tons of labs in Rails, I was not comfortable with Rails.
RoR is great but its too much abstract and if you do not do something about this abstraction then abstract frameworks start growing on you and as you were excited by the magic of Rails, it starts to fade away.
I was so much frustrated by the abstraction that I gave up and kept making excuses for programming. After some time, I realized that I did wrong and I should have started from basics rather than quitting. I re-did all the basics, procedural, object-oriented, and then eventually Sinatra.
What was the right thing that I did this time? Whatever I learned, I reflected on it. I repeated it over and over again until the tough concepts synced with me. I deliberately practiced difficult stuff multiple times, other than course work help, I searched on the internet about a concept that I wanted to completely comprehend. I wrote blog posts about difficult topics. Through all this following happened...
- I started loving abstraction and begin to accept abstraction. I have realized that abstraction is one of the important parts of our life and programming. Some day I really want to write a comprehensive blog post on abstraction, if God wills.
- I have gotten much better at handling impostor syndrome.
- I’m starting to understand different levels of abstraction
Now let's talk about how Sinatra helped me to become confident about Ruby on Rails. Sinatra is a very low-level Ruby framework, it's abstract but nothing as compared to Rails. Learning Sinatra helps one to become confident about large frameworks like Rails.
In Sinatra, you are given nothing, no generators, no helpers, or anything special, no database setup. You have to do everything by yourself. Now if you carefully build a Sinatra app from scratch, you can demystify most general abstract concepts of Rails.
- Setting up an environment which loads all of your application requirements
- Working with bundler in advanced ways
- Setting up a database for development and test
- Setting up the test environment
- Model View Controller paradigm
- RESTFUL Routes architecture
- HTTP actions or methods like POST, GET, PUT, PATCH, DELETE
At this point, I’m much comfortable with the above concepts and now I’m confident that by God's will, Rails will not grow on me and I will be able to master Rails and continue learning always.
Coming to the production environment. Before, I always got scared by realizing that one day I have to put my apps into production. But this time after completing my Sinatra app, through the inspiration of looking at one of my fellow colleagues putting a Sinatra app in production, I also decided to put my app in production. I used Heroku for production and it was a lovely learning experience by interacting with Heroku. Heroku is very awesome and takes care of everything if you follow their guides.
Today because of learning Sinatra, I’m serious and excited to master Rails with confidence. Using Sinatra, I was able to deploy on Heroku. I’m so much excited to put every single app into production using Heroku. You can host as many apps as you want for FREE on Heroku, works great as a sandbox. It has some limitations but their pricing is also very reasonable.