Encapsulation
I
wear a man's jacket on that day (with inner pockets!) and a brooch
on the lapel. I say: I am an object. I offer you many interesting
methods, like this nice brooch you see. If you use the method,
I go into my pockets - my hidden variables and fields - and figure out
what it is that you want and return that value. For example,
you might ask me how old I am - that could be a method,
getAge (Person p). I open my pocket and take out a card - you don't
know if I have my birthday written on here and I look at my armband
watch to determine how old I am, or if I keep my age on the
card and wake myself up at midnight every night to add a day
to the age on the card. After doing my calculations I will
let you know the result, and this is all that you really wanted
to know, not how I arrived at the result.
[Note: check the contents of your pockets the day you do this
and remove any embarrassing material. I grabbed one day what I
thought was a packet of nose tissues, it turned out to be a
sanitary napkin... guess I got quite red on that one!]