Let me start off by saying I had zero coding experience prior to signing up for the Software Engineering course at the Flatiron School. And this has been one of the most demanding and rewarding experiences of my life. In this article I will be explaining what I’ve learned in the past few weeks.
In my first week we learned Object Oriented Programming(OOP) through Ruby. We started with the easy stuff on the first day, orientation in the morning then some “ lab” work in the afternoon such as setting up our developer environment , learning how to use the Command line console and getting familiar with Git basics for version control. However, once the second day started, we kicked it into high gear( 8hours of class and 3–4 hours of homework to be exact) and spent the rest of the week learning OOP and how to make individual instances relate to each other in programming through classes. When I say classes I don’t mean my classroom, I’m referring to how You, the reader(instance) belongs to the Medium.com Users(class).
OOP Concepts that I’ve learn
- Doctor(class) can HAVE MANY Appointments(class)
- Appointment(class) can BELONGS TO a Doctor(class) and a Patient(class)
- Doctors(class) can HAVE MANY Patients(class) THROUGH Appointments(class)
- The Appointment Class in this case is referred as a JOINER class
This example would be great if we were making an app for clinics or hospitals to display their schedules for the day with unique info such as which patient is suppose to meet with their assigned doctor or how much the appointment would cost for the patient.
The schedule for week two was similar to the first, very high paced but this time around we had our first Code Challenge on Tuesday ,which was the hardest thing I had to do in class so far. Mid week we learned about a super useful tool called Active Record and Sqlite3 which are ruby gems. These can be installed by running
gem install activerecord &
gem install sqlite3. Active Record is a Gem that has a collections of methods built in by the ruby community , methods that will help you bypass writing the basic CRUD methods manually .What is CRUD you ask?
- Creating new instances
- Reading information
- Updating information
- Deleting information
The code above is how I would start building out the models for the clinic app to be able to create/find/update/delete any appointments through a doctor or a patient .
Below are the models but with the Active Record Gem .
Next you need to run
rake db:create_migration NAME=create_#class in your terminal to create a migration file in the sqlite3 db.
after that you should see new files in a new folder named db/migrate. you would write your create tables for each class there.
As coders we are lazy(supposedly) … We want our clinic app to do other things than just create/delete appointments. What if we want to find a doctor by location or see if the clinic can accept a patient according to their health insurance. That is where Active Record comes in real handy. Active Record already comes with a a bunch of useful function prebuilt in.
Now our app can perform actions such as..
- .create -to create new instances
- .patient/.doctor -to read or update doctor or patient for an appointment
- .delete -to delete any instances
- .all -to find the list of all doctors/patients/appointments
- .find -to find any doctor or patient by their attributes
- .first -to find the first appointment of the day if needed
These are just a few examples of Active Record functions we can use without hard coding it in ourselves, now that’s some useful CRUD right there.
Hurray !! I barely passed my code challenge from last week and now on to the next challenge, project time. Great stuff. I really meant it when I said this has been one of the most demanding experiences of my life. I keep seeing these references about how learning to code is like trying to take a drink from a running fire hose and I get it now.
Fortunately , I get to work with a classmate for this project which I’m super thankful for. Another thing I’ve learned in the past few weeks is that I have a great cohort. I’ve been a working adult for the past decade and going back into a school environment has been really hard, physically and mentally and without the emotional support from my classmates and my partner I don’t know how I would’ve stayed sane the past month. I’ve even gotten to enjoy the 8pm discord homework session with my classmates. Now I just gotta learn how to drink from a fire hose….
I hope you enjoyed this article , follow me on Github if you’re interested in my journey. I’m sure more blog posts will be coming in the future. Will definitely write a another post about my soon to come CLI application.