Page 225 - DCAP408_WEB_PROGRAMMING
P. 225

Unit 9: ASP Objects




          Let’s look at each of these aspects in turn:                                          Notes






















          How It Works
          The three categories that we have created in the left-hand column can be applied to any object.
          In fact, the best way to describe an object is to break down its characteristics into these three
          categories, and put information about your object into these categories. Any information that
          you have about a particular object can be included in one of these categories.

          If you have another telephone that features all these characteristics, except that its color is blue,
          then we can describe your telephone by changing that one part of the description above. Moreover,
          this technique works for any type of object, both real world and software.
          9.1.1  The Building Blocks of Objects (Properties, Methods, Instances of
                 Objects)


          Object Terms

          So far, we have used verbose English terms to describe our three categories. In the world of
          objects, we need terms that concisely describe each of these three categories. These terms are
          properties, methods and events. In addition to these terms, we need to look at the term instance
          as it relates to objects. In this section, we’ll look more carefully at what each of these means in
          abstract terms.

          Instances and Classes

          When we are talking about a unique object, we can use the term instance to say that we are talking
          about a particular telephone object - your telephone for example - that has a specific set of properties
          and values. When we want to talk about another telephone, we use a different instance of the
          telephone object. In this way, both you and we can have instances of the telephone  object.
          For example, my telephone (my instance of a telephone object) is gray and comes with special
          answer-phone facilities, your telephone (your instance of a telephone object) may be red, blue,
          green, etc. These instances represent completely different physical objects. However, since they
          are both instances  of the same object description or template, they share the  same types of
          characteristics such as methods, properties (although the values can be different), and events.
          When a specific instance of an object is created from the template for the object, the object is said to
          have been instantiated. What actually happens is that a copy is made of all of the properties and
          events from the object description, but the methods (frequently a big chunk of code) remain in the
          original place and this section of code is used by all of the different instantiations of that one object.



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