Join Kevin Skoglund for an in-depth discussion in this video Override and extend, part of Ruby: Classes and Modules.
- [Instructor] Now that we understand the basics…of class inheritance,…I want to talk more about overriding and extending.…These are the main reasons…that we want to create subclasses.…I mean, obviously, we want to inherit a lot of the behaviors…of the parent class,…but on it's own, that's not enough.…Otherwise, we just have a new class…that acts exactly like the parent.…Overriding and extending is what allows us to modify…those behaviors so they can't be unique to the subclass.…We either override behaviors which we want to perform…differently in the subclass,…or we add new behaviors in the subclass…that the parent doesn't have.…
And that's extending.…Let me give you an example in code.…Let's say that we have a parent class called Sofa.…It has a class attribute called can_open…which is set to false.…And I've got an attribute accessor…for the width and the length.…And I've also got a method called area…which returns the area of the sofa.…The idea being the amount of space…it takes up on a floor plan.…So it's the width times the length…
Author
Released
11/20/2018- Defining a custom class
- Working with instances of a class
- Class and instance attributes and methods
- Class inheritance
- Working with dates and times
- Using modules as namespaces and mixins
- Raising and handling exceptions
Skill Level Beginner
Duration
Views
Related Courses
-
Code Clinic: Ruby
with Kevin Skoglund5h 42m Intermediate
-
Introduction
-
1. Classes
-
Define a class4m 37s
-
Instances5m 32s
-
Attributes4m 17s
-
Reader/writer methods5m 8s
-
Attribute methods5m 34s
-
Method access control7m 20s
-
Initialize method4m 51s
-
Challenge: Dice3m 39s
-
Solution: Dice4m 58s
-
-
2. Class Attributes and Methods
-
Class methods6m 47s
-
Class attributes4m 55s
-
Class reader/writer methods3m 31s
-
Challenge: Radio4m 48s
-
Solution: Radio4m 36s
-
-
3. Inheritance
-
Class inheritance8m 31s
-
Override and extend7m 6s
-
Access the superclass7m 18s
-
Challenge: Secure radio5m 14s
-
Solution: Secure radio6m 19s
-
-
4. Dates and Times
-
5. Modules
-
Namespacing4m 56s
-
Mixins4m 58s
-
Load, require, include4m 6s
-
Challenge: To-do list6m 2s
-
Solution: To-do list3m 39s
-
-
6. Exceptions
-
Handle exceptions6m 4s
-
Handle specific exceptions5m 16s
-
Exception methods4m 2s
-
Raise exceptions6m 10s
-
Custom exceptions6m 59s
-
Challenge: Custom exceptions1m 39s
-
-
Conclusion
-
Next steps47s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Override and extend