Fast forward 2.5 months into my coding bootcamp, and I am learning the ropes of Rails. So, now that I’ve learned and built a project using a framework, how would I define a framework to a total code newbie? Frameworks, and in this case Rails, didn’t make learning how to code any easier, but it did lay out a lot of groundwork so I could hit the ground running with building my web application. Frameworks use abstraction (high level code) in order to provide a foundation to build off of. For example, typing rails new unicorn creates a directory which provides a standard layout of how to organize the files within your application named unicorn. Also, Rails comes with generators in which you can create tables from the command line, instead of having to create a file in your text editor and write out the code in the file in order to create a table. Not to mention, the infamous scaffold generator, which creates CRUD functions for a model by typing out one line in the command line!
In short, you can think of a framework as a piece of software built because someone identified that there was similar code/ patterns that had to get built out each time a new application is built. In the context of Rails, David Heinemeier Hansson put in the legwork in order to make it more efficient for other developers to build an application. There’s even extensive and fantastic documentation to demonstrate how to use the framework.
I remember bringing this topic of “What is a framework?” up with one of my instructors. I first told him what my initial idea of a framework was— training wheels, since frameworks do a lot of the work for you. However, this setup is not trivial. It’s important to understand Ruby well before jumping into Rails, so you are able to understand and have context with the magic (really abstraction) of Rails. My instructor opposed my analogy, and instead, he said think of using frameworks as standing on the shoulders of giants. Well said.