Summary

This chapter covered a lot of important concepts. This chapter's primary goal was to examine how OOP can be utilized to limit duplicate code and share core functionality between subclasses. Initially, we walked through a real-world example of OOP and saw how to implement setters and getters in Ruby classes. You looked at the concept of instantiation and learned the initialize method in Ruby, including its syntax, when it can be helpful to use, and various options you can pass to it in order to perform tasks such as setting default values.

We saw one of the important building blocks of OOP development: inheritance. The key to remember about inheritance is that it gives you the ability to clean up your codebase and create inherited classes that share common behavior. We reviewed the differences between private and public methods in Ruby classes. We analyzed how to categorize methods and we took a high-level view of method visibility.

Another important concept of OOP that we walked through was the concept of polymorphism, which is simply a tool in your OOP arsenal that allows you to alter the behavior of parent methods in a subclass.

Lastly, we looked at the SOLID (SRP, open/closed, LSP, ISP, and DIP) design principles.

In the next chapter, we'll analyze how to work with the Ruby filesystem.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.152.157