Object Orientation/Instance Methods

Posted by Jesse kathryn on June 20, 2019

You can easily keep track of your objects and variables when storing or accessing them through using specifically named instances that begin with the @ symbol, known as an instance method. It makes me happy to know that I can build little methods that later will be used in other methods and at the end of the work– it all fit together like a nice little puzzle.

Remember (especially all you 90s kids) doing the puzzles back in the day during the summer or on vacation with the family? Or on board game nights on the weekend?

literally just had to type in “paper puzzle old school” in google to get non-digitalized games

of course let’s reference a Disney Princess puzzle

Instance methods (inside instance methods are also instance variables, which can begin with @ symbol as well, but these act more as attributes rather than the method itself) as pieces of the puzzle/objects building your program

Instance methods are like each of the 50 different little puzzle pieces you move around to fit together and build the picture on the top of the box. In code, instance methods use instance variables or other objects within the class to make a program work through running methods in order to access each variables/objects, or attributes. Instance methods are a part of the class in which they are written within (like the many pieces within a puzzle box)… The scope of the instance method is confined to the object that self refers to..

As you piece your methods together through instance methods, you get a working program! Just as you get a clean picture, nice pretty disney princess puzzle after arranging the puzzle pieces.

Ta-da!