The Object Model Flashcards
What does Encapsulation do?
Hides certain processes from the rest of the code base; so that this data cannot be affected unintentionally
The ability for different types of data to respond to a common interface
Polymorphism
Through ___ , programmers can define basic classes with large reusability and smaller ___ for more detailed behaviors
Inheritance, subclasses
___ are similar to classes in that they contain shared behavior
Modules
(T/F) You can create an Object with a Module
False; only Classes can create an Object
Modules must be ___ __ with a class using the __ method
mixed in, include
State refers to…
the data associated to an individual object
Behaviors are…
what objects are capable of doing
Instance variables are how we keep track of ___
States
The initialize method is what type of method?
Constructor method
Instance variable has this symbol before its name
At sign (@)
Until when does an instance variable instance exist?
As long as its object exists
We allow objects to have behaviors with
Instance methods
A getter method does what?
It allows you to access an instance variable
A setter allows you to…
change the data associated with an instance variable
The built-in Ruby way to create both the getter and setter methods
attr_accessor
The built-in Ruby way to create a getter method
attr_reader
The built-in Ruby way to create the getter method
attr_reader
The built-in Ruby way to create the setter method
attr_writer
Instead of using the instance variables directly in instance methods, use…
the instance getter method
In order to specify to Ruby that you are not initializing a local variable you must…
precede a setter method with self