How did you make it a subclass?

Hey, how did you make it a subclass?

Grade and Student are independent classes. Neither is a subclass of the other.

Where would we find both objects? In a classroom, perhaps? So what if we made Class our parent class, and let Student and Grade both inherit from the parent?

class Class:
    pass
class Student(Class):
    pass
class Grade(Class):
    pass

Now the two classes are subclasses. This is a design consideration. We are not told to do this. We do it of our own volition according to our implementation plan.

1 Like

Why are we told not to do this?

We are not told ‘not to do this’. We are ‘not told to do this.’ In other words we’re not following a play book. We write the play book. It’s our implementation, not something we’re being directed to do. Programmers start with a task they want to accomplish, then they formulate ideas, then they plan the steps to carry out those ideas, then they implement and test to make sure they get what they expected as the outcome. We are the planners, the thinkers, the implementors.

Take the FizzBuzz problem. We are told what the output needs to look like and then set to work planning how we would generate that output. There are no directions. It’s up to us to think through the problem and decide what is needed, then make it so.

1 Like