Campbell wrote:In its most basic form, a bean is an object with a no‑arguments constructor and getXXX() and setXXX() methods for each field. Any field can be used to remember information from a previous method call. What would you want to remember?
An object can only “see into” a calling object if that object passes information on to it; remember methods don't “know” where they were called from.
I read this from two years ago and it got me thinking about classes in a different way. It seems as if they have a lifetime.
The class gets instantiated and follows rules in its constructor class if it has one.
It lives in the heap.
On the stack there is a reference variable.
It is there but doesn't do anything. I'm not sure about this part. If I make a frog object can it do frog stuff like hopping while the rest of the code is performing other tasks?
I"ll call it an object now that it has been instantiated.
The object sees something calling it. It looks for a match of object types and position. It uses the one that matches.
It does things. It can remember things from the last time it was used.
I t will return values if the private, public grantors allow it.
When the method is done it might return a value to the calling line of code.
If all references to the object are removed, they object will eventually get sent to garbage disposal.
I don't know if you are familiar with the Saturday Morning TV show called "School House Rock". There was a catchy cartoon with funky music explaining the life of a USA Bill in Congress. They showed the bill from the viewpoint of the Bill. If I was better at music, Id write a song about the life of a Class.