Page 226 - DCAP408_WEB_PROGRAMMING
P. 226

Web Programming




                    Notes          So we’ve mentioned object descriptions or templates, but it’s time to give them their proper
                                   name in ASP; classes. We mentioned that each object can have different instances. For instance,
                                   my telephone is small and white and has 12 buttons. Your telephone will probably be different
                                   to that, but they’re both recognizable as telephones and they both provide the same function.
                                   They both conform to a  set  of rules for what  a telephone  does  - they connect  to the local
                                   telephone line, they both have a numeric keypad and somewhere to speak into. A class in ASP
                                   is like a set of design rules that an object must conform to. It would be no good if my telephone
                                   didn’t have a handset, or a numeric keypad, even if it did plug into the telephone socket on the
                                   wall.

                                       !
                                     Caution  In a class there should be a minimum set of functions that your object must be able
                                     to perform.

                                   Properties

                                   When talking about those characteristics that describe an object, we are talking about the properties
                                   of the object. Each property of the object describes a particular aspect of the object. The property
                                   is actually described as a name/value pair. This means that for every named property, there is
                                   a single unique value that describes that property for this instance of the object. If we go back to
                                   our telephone example, we can create a table that lists each of the property names and the value
                                   of each property.

















                                   We now have a set of properties that describe this instance. The properties of an object are used
                                   to represent a set of values associated with the object. A new instance of the object may have
                                   different property values, but it has the same property names.















                                   Even with different property values, these two telephones are instances of  the same  object
                                   template. Since we know that all telephone objects have a ‘Color’ property, we can determine
                                   the color of each of the phones by examining its ‘Color’ property value. We can use properties
                                   in two ways. We can read from them or we can also write to them. So if we wanted, we could
                                   have changed the cover of our telephone to a different color, if we required.



          220                               LOVELY PROFESSIONAL UNIVERSITY
   221   222   223   224   225   226   227   228   229   230   231