Classes and objects

Object-oriented programming is a paradigm that has become the foundation of many modern programming languages, and it's at the core of Ruby. In short, the object-oriented programming sees the world as data, modeled in code by "objects". When working with data, this model of programming is most apt, as it allows us to model our program as we would see the real world.

The object-oriented programming paradigm, or OOPs as it's popularly called, is based upon a few principles, let's look at them one at a time:

  • Encapsulation: This is a concept that ensures a certain functionality is hidden from the rest of the code. Its primary use is to ensure that the underlying data is protected, and can only be manipulated in a way the object desires. ...

Get Mastering Chef now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.