02 January 2011
Now that Bob can protect his personal belongings, we have a problem with adding new capabilities.
If we add capabilities through a prototype on Guy, the method will not have access to “stuff.”
Introducing the magic word, please. When you ask Bob nicely, he’ll do something with his stuff.
To make sure you don’t trick Bob into giving away his stuff, please will return undefined.
This may allow us to move some of Guy’s capabilities out of the class and into the prototype for
better code organization and reuse. Because please does not return, we can only move “keep.”
This works great and allows us to extend Guy’s functionality without modifying our class.
The problem comes when we want access to the “find” method from our prototype methods.
We also still have an issue with how Netbeans sees the person object:
Next we’ll finally figure out that Person should be a class too.