Object Outsides vs. Insides


  • Identity and interface correspond to the object's outside
  • An object's inside corresponds to its physical representation, algorithms, and general structuring 


Detailed description: 

         "Let's look at another object, a bank account object.  This is a review for those without object-oriented backgrounds to give you a little more depth in object orientation. 
        Again, we've drawn a doughnut on the right side, and that lets us describe the bank account object.  My typical notation is to put the class name at the top and the instance name or object name at the bottom, if it's available. 
        Internal to the center of the object, we have two pieces of information.  They are instance variables or data, and in this case, there is an id field and a balance.  This seems reasonable for any bank account that we might have. 
        Surrounding the outside of the bank account are the behaviors or the methods. And these methods then implement whatever functions are necessary. In this case, for the bank account, there will be a deposit, a withdrawal, and some other functions to inquire or access the information that's in the center, the id and balance fields.  Another unique thing about the Java language is that there's a typical way to get a string value for an object; it's called toString.  Its job is to take the object's internal content and produce an output string that can be printed.  It's also used for diagnostic purposes. 
        So, as we said, there's the inside and outside.  Inside the object is the data and also the actual computational aspect of what the method is, the body, which we call the behavior. 
       Outside the object are two things.  The first is the identity of the object.  The identity is the variable or the instance name.  In this example, the identity of the object is held by aBA.  It represents a bank account.  The identity is related to the object's address. 
       All objects are uniquely identified by their address.  The memory address is different if you have different pieces of data.  Just remember that objects have an identity, and the identity is related to the object's address. 
      Another thing that is on the outside of an object is its interface, which is 
somewhat bound with its behavior.  Recall that the interface of an object is just the outer shell of the doughnut that we see here.  It represents that we have a deposit method that takes no parameters and returns a certain type of result.  It has a withdraw method.  It doesn't say what its body is.  It's purely the signature of the method, and that represents the interface.  In Java, there's actually a special construct, called an interface, that provides something like this.  What we're doing now is just talking about the general object-oriented term -- interface."