Page

6.2.0- Programming with Objects

  by NT Community Manager.
Last Updated  by Jim Minatel.  

PublicCategorized as 06. Objects, Properties, Methods and Events.

Not tagged.
<< 6.1.2- Object TermsChapter66.2.1- The Software Telephone Object >>

Programming with Objects

To begin our look at programming with objects, let's use our trusty telephone object again. Being a technophile and always needing to have the latest and greatest, you have even hooked up your telephone to your computer. Now you want to be able to do something with it. If we want the computer to interact with the telephone, we need a programmatic object that will allow us to control the physical telephone.

 

It is this representation of a physical object that gives programmatic objects their power. Representation is literally the process of taking our real world object and turning it into a software object. In our telephone object example the color of the phone is represented by a color property, the weight of the phone is represented by a weight property. The ability to pick up the receiver and dial a friend is modeled by the PlaceCall method. The real world telephone has a set of features or characteristics that can be broken down into properties, methods and events. Once we have identified these features it makes it easier, to represent them in our software object.

 

However, as described in the previous section, the concept of encapsulation means that the actual workings of the telephone object are hidden from us. When a phone rings, you don't need to know how the signal was transmitted to the exchange, you only need to interact with the interface (talk into the handset). This is what we're going to consider with our software object; the interfaces we use to communicate with it, rather than the software object itself. So when we use our computer to control our object, it's not going to use the inner workings of the objects, rather it's going to communicate with the object and control it using its interfaces (the methods and events).

 

 543636_pg225.jpg

This book will not cover how to create the software object itself (you will be able to download this from the Wrox website – details of this are in the Try It Out coming up): rather, we will take a look at the programmatic object, and then look at how we can use the object's properties, methods, and events.

<< 6.1.2- Object TermsChapter66.2.1- The Software Telephone Object >>

Copyright © 2003 by Wiley Publishing, Inc.

Powered by Near-TimeTerms of Services | Privacy Policy | Security Policy |