From the course: Programming Foundations: Object-Oriented Design
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Solution: Jukebox class relationships - Python Tutorial
From the course: Programming Foundations: Object-Oriented Design
Solution: Jukebox class relationships
- To solve the final challenge of identifying class relationships, we'll begin by looking for classes that have similar attributes or methods. The first thing I notice is that the User and Admin classes both have an 'id' attribute and a 'getId' method. This is a hint that there might be an opportunity for inheritance here. So, to test that idea, just ask if the phrase 'User is a Admin' makes sense. - [Olivia] Well, a User could be an Admin. That's not always the case. - [Man] Then how about 'Admin is a User'? - [Olivia] That makes more sense. An admin is a type of user with extra capabilities. So, in this case, User can act as the super class which the Admin class can inherit from. Notice we've removed the id attribute and 'getId' method for the Admin class in this diagram since they'll be inherited from the user. Using inheritance here could come in handy down the road if we decide to implement additional types of special users. - Like a musical curator who updates the songs to keep…
Contents
-
-
-
-
-
-
-
-
(Locked)
Identifying inheritance situations4m 55s
-
(Locked)
Using inheritance2m 44s
-
(Locked)
Abstract and concrete classes3m 10s
-
(Locked)
Interfaces4m 15s
-
(Locked)
Aggregation2m 3s
-
(Locked)
Composition1m 45s
-
(Locked)
Challenge: Jukebox class relationships1m 6s
-
(Locked)
Solution: Jukebox class relationships3m 20s
-
(Locked)
-
-