To learn a bit more about inheritance in Ruby, we were given this assigment to work through, in which we modeled Dev Bootcamp's cohort structure and schedule. I created a GlobalCohort class, a sub-class to that called LocalCohort, which was city-specific, and an additional Student class. Here's GlobalCohort:
I think the interesting part for this class is the way it is able to model and give information about the phase schedule based on the start date. I've worked with the Date class only a bit, when I created the deadline counter, so this was a welcome continuation of that. And now for LocalCohort:
This class was meant to be much simpler; the important difference between it and GlobalCohort, in my design, was to make LocalCohort the location where I would add Student objects, so that students were always organized by their LocalCohorts, or cities. Now for Student:
Also simple. This one needed to be able to store the student's information, like name, email, and history of events like quizzes, and to be able to know which global cohort and which city the student was going to belong to. Everything else was designed to be found for the entire group, and therefore stored in GlobalCohort. Output:
Conceptually, this gave me a ton of problems, because I went into this challenge thinking that
it was possible for instances in a class chain—skippers to nyc to esther_leytush—would be aware
of each other in both directions, and have access to attributes. But of course this isn't the case;
instances of Student don't and in fact should not have access to the attributes of instances of LocalCohort,
for example, because they should not be able to change the LocalCohort's state. Once this clicked for me,
I stopped getting so many nil
errors, which was nice. And I definitely think I got some
good practice with interconnected classes and modeling real-world scenarios.