<< Chapter < Page Chapter >> Page >
Most modern car radios are much more complex than the one that we will use as an analogy in this module.

The user interface

The radio provides a mechanism (user interface) that allows you to use the data stored therein. When you press one of the station-selector buttons on the front of the radio, the radio automatically tunes itself to the frequency corresponding to that button. (In this case, you, the user, are sending a message to the radio object asking it to perform a particular action.) If you have previously stored a favorite radio station frequency in the storage location corresponding to that button, pressing the button (sending the message) will cause the radio station transmitting at that frequency to be heard through the radio's speakers.

If you have not previously stored a favorite frequency in the storage location corresponding to that button, you will probably only hear static. (That doesn't mean that the radio object failed to respond correctly to the message. It simply means that its response was based on bad data.)

Modifying the stored data

The human interface also makes it possible for you to store or modify those five or more frequency values. This is done in different ways for different radios. On my car radio, the procedure is:

  • Manually tune the radio to the desired frequency
  • Press one of the buttons and hold it down for several seconds.

When the radio beeps, I know that the new frequency value has been stored in a storage location that corresponds to that particular button.

What I have done in this process is to send a message to the radio object asking it to change its state . The beep that I hear could be interpreted as the radio object returning a value back to me indicating that the mission has been accomplished. (Alternately, we might say that the radio object sent a message back to me.)

Responding to a message

We say that an object has changed its state when one or more data values stored in the object have been modified. We also say that when an object responds to a message, it will usually

  • perform an action,
  • change its state,
  • return a value, or
  • some combination of the above.

After following this procedure to program a button, when I press that button (send a message) , the radio object will automatically tune itself to that frequency.

I live in Austin, TX. If I drive to Dallas and press a button that I have associated with a particular radio station in Austin, I will probably hear static. In that case, I may want to change the frequency value associated with that button. I can follow the same procedure described earlier to set the frequency value associated with that button to correspond to one of the radio stations in Dallas. (Again, I would be sending a message to the radio object asking it to change its state.)

Jargon

As you can see from the above discussion, the world of OOP is awash with jargon, and the ability to translate the jargon is essential to an understanding of the published material on OOP. Therefore, as we progress through this series of modules, I will introduce you to some of that jargon and try to help you understand the meaning of the jargon.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Itse 1359 introduction to scripting languages: python. OpenStax CNX. Jan 22, 2016 Download for free at https://legacy.cnx.org/content/col11713/1.32
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Itse 1359 introduction to scripting languages: python' conversation and receive update notifications?

Ask