Ruby Red — my favorite color
Today marks the end of my second week, out of 15, in Flatiron school’s Software Engineering Immersive program. Up until exactly 14 days ago, I had never written a line of code. I could not imagine the amount of code I could learn in just 2 short weeks, and I have surpassed all my expectations so far! If I can do this, so can YOU!
(I feel just as cool as this pineapple while using OOP)
The first Object Oriented Programming language that my cohort is learning is Ruby (Ruby red — my favorite color!!). In this blog I am going to share some KEY information that is of extreme importance and VALUE if you are going to tackle this challenge of learning to code an OOP language! (For those of you who already code, I hope you caught that hash joke 🧐…) In this blog we are going back to the basics — describing the difference between a class and an instance. Although I call this basic, it should not be considered simple, and NEVER be overlooked!
To make this topic easier to understand, we need to make it relatable. Imagine you are a software engineering student studying in an immersive cohort in Chicago. You — one student — are among many other students, which together make up a cohort. You and the others may have some differences, and some similarities.
Think for a second…what does every student in this cohort have in common?
- First off, every student must be a student.
2. Every student must live in Chicago.
3. Every student must own a computer.
4. Every student must LOVE to code.
Now, think for another second… what can you, an individual student, have that other students in your cohort may not have?
- You have zero experience coding, while others may have worked in tech prior.
2. You live in the city, while the other students, live in the suburbs.
3. You have a Macbook Pro, while the other students all have a Macbook Air.
Now you may be asking yourself…. WHAT’S WITH ALL THE QUESTIONS?!?!
These questions are all examples of what makes something a class versus an instance.
CLASSES:

In our example, the cohort is a class. In Ruby, a class is like the building blocks or blueprint for many objects that belong to it. A class (cohort) has the ability to create new objects, and give each of those objects the same attributes from the second they are created. Back to our example. The Software engineering cohort is a class. It creates new objects (students) by teaching them. When a student joins the cohort, they are automatically given a few attributes: every student is a student, every student lives in Chicago, every student owns a computer, and every student LOVES to code. Regardless of the student, they are in the same class/cohort.
INSTANCES:

In our example, you — one individual student — are an instance. In Ruby, an instance serves as an individual sample that belongs to the class. It has all characteristics that the class gave it when it was created. HOWEVER, a single instance is different from all other instances. Each instance, when created, is given an object ID (in our example this would be a student ID #), and no object ID ever repeats. Each instance/student has their own address, their own prior experience, and their own computer.
Now you may be asking yourself… whats the advantage of being part of a class? GREAT QUESTION!
As a student, or instance, when you are created you automatically have the traits the class gave you, without ever having to let anyone or anything know! By being in the cohort class, you automatically are considered a student, live in Chicago, and LOVE to code! As programmers we are lazy and want to create the most relationships the quickest, and most efficient way. By being part of a class, you are given information, and automatically you are built into a relationship!
Now that we understand the not so basic basics of OOP, we can move on to the nitty gritty… @variable, @@variable, and SELF…
but lets do that another time…