home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / SOMINF.ZIP / SOMOOPS.INF (.txt) < prev    next >
OS/2 Help File  |  1992-07-24  |  13KB  |  250 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. What is an Object? ΓòÉΓòÉΓòÉ
  3.  
  4. o The encapsulation of data and its methods. 
  5.  
  6. o An item that can be manipulated as an independent unit, and that a user could 
  7.   work with to perform a task (CUA) 
  8.  
  9. o Objects communicate via messages 
  10.  
  11. Real-life objects: 
  12.  
  13. o printers 
  14. o mail in-baskets 
  15. o mail out-baskets 
  16. o file folders 
  17. o file cabinets 
  18. o desktops 
  19. o shredders 
  20. o a book 
  21.  
  22.    - can be read 
  23.    - can be stored and retrieved 
  24.    - can be discarded 
  25.  
  26.  
  27. ΓòÉΓòÉΓòÉ 2. Why Object Oriented Programming? ΓòÉΓòÉΓòÉ
  28.  
  29. Existing Software Problems        Detail 
  30.  
  31. Long Development Cycles           most software developed from scratch -- lack 
  32.                                   of re-usable code 
  33. Frequent Modifications            changing existing software usually creates 
  34.                                   other problems 
  35. Non-Intuitive Coding Techniques   diverse ways to pass control, information -- 
  36.                                   severe learning curves 
  37.  
  38. OOP Solutions                     Detail 
  39. Readily Re-usable Code            libraries of objects can be used for multiple 
  40.                                   projects 
  41. Easily Modified                   so long as the methods remain constant, the 
  42.                                   internals are transparent 
  43. Real World Model (intuitive)      the world is comprised of objects 
  44.  
  45.  
  46. ΓòÉΓòÉΓòÉ 3. What is a class? ΓòÉΓòÉΓòÉ
  47.  
  48. o A description of the underlying data interface 
  49.  
  50.    - includes both data and operations 
  51.  
  52.    - operations are implemented by methods 
  53.  
  54.    - thus, a class contains both data and methods 
  55.  
  56. o Permanent template or model from which new objects are created 
  57.  
  58. o An object is an instance of a class 
  59.  
  60.    - an object is a variable declared to be of some specific class 
  61.  
  62.    - several objects of a class can exist at once -- these are instances of the 
  63.      class 
  64.  
  65. o Objects exist only during run-time -- classes are static system elements 
  66.  
  67.  
  68. ΓòÉΓòÉΓòÉ 4. Inheritance ΓòÉΓòÉΓòÉ
  69.  
  70. o Properties of a class (data and/or methods) can be passed along (inherited 
  71.   by) other classes 
  72.  
  73. o A subclass has all the properties of its parent (the Superclass) 
  74.  
  75. o Multiple Inheritance is where a subclass may inherit from multiple parents 
  76.   (this is available in C++, but not in Smalltalk/V PM) 
  77.  
  78. o There are three degrees of inheritance: 
  79.  
  80.     1. No redefinition of methods in a subclass 
  81.  
  82.     2. Redefinition allowed, but must give the same result (also known as 
  83.        subtyping) 
  84.  
  85.     3. Redefinition can override the original definition, even if these now 
  86.        contradict (this is the degree of inheritance used by Smalltalk) 
  87.  
  88.  
  89. ΓòÉΓòÉΓòÉ 5. Inheritance Hierarchies ΓòÉΓòÉΓòÉ
  90.  
  91. IS A --> Class relationship 
  92.  
  93.                     ANIMAL
  94.                     /    \
  95.                  BIRD   MAMMAL
  96.                   /        \
  97.             SPARROW     PRIMATE
  98.                         /      \
  99.                      MONKEY   MAN
  100.  
  101.  
  102. ΓòÉΓòÉΓòÉ 5.1. Inheritance Hierarchies (continued) ΓòÉΓòÉΓòÉ
  103.  
  104. PART OF --> Object relationship 
  105.  
  106.  
  107.                 HOUSE
  108.                /     \
  109.             ROOF      WINDOW -------------------------
  110.             /   \               |         |         |
  111.        SHINGLES  NAILS        PANES     GLASS     LOCKS
  112.  
  113.  
  114. ΓòÉΓòÉΓòÉ 5.2. Class Inheritance Example ΓòÉΓòÉΓòÉ
  115.  
  116. "IS A" for PM Windows 
  117.  
  118.                     OBJECT
  119.                       |
  120.                     WINDOW
  121.                    /      \
  122.             APPLICATION   CONTROL
  123.              /    /          \   \
  124.           TEXT  GRAPHICS    MENU  FRAME
  125.  
  126.  
  127. ΓòÉΓòÉΓòÉ 6. Polymorphism ΓòÉΓòÉΓòÉ
  128.  
  129. o Ability to send the same message to objects of different classes 
  130.  
  131. o Allows generic operations to be performed in a global environment 
  132.  
  133. o Example: 
  134.  
  135. delete message may mean different things to different objects 
  136.  
  137. The term operator overloading refers to the same operator (such as "ADD") 
  138. behaving differently when used to send a message to different object types. 
  139.  
  140.  
  141. ΓòÉΓòÉΓòÉ 7. Object-Oriented Programming Design Methods ΓòÉΓòÉΓòÉ
  142.  
  143. o object-based (not function OR data individually) 
  144.  
  145. o the challenge is in defining the classes properly 
  146.  
  147. o often more "art" than "science" 
  148.  
  149. o brainstorming class definitions is helpful 
  150.  
  151. o project leads architect classes, remainder of staff implement 
  152.  
  153. o re-definition of classes is common 
  154.  
  155.  
  156. ΓòÉΓòÉΓòÉ 8. Definitions for Object-Based Languages ΓòÉΓòÉΓòÉ
  157.  
  158. An object-oriented language is: 
  159.  
  160. o object-based 
  161.  
  162. o class-based 
  163.  
  164. o capable of class inheritance 
  165.  
  166.  
  167. ΓòÉΓòÉΓòÉ 9. Object-Oriented Languages ΓòÉΓòÉΓòÉ
  168.  
  169. Language                Notes 
  170.  
  171. C++                     AT&T--Bjarne Stroustroup 
  172. Smalltalk/V PM          Xerox-Digitalk 
  173. Simula67                1967 
  174. Objective-C             Brad Cox 
  175. LOOPS                   LISP based 
  176. Eiffel                  Bertrand Meyer 
  177. Object PASCAL           Apple 
  178.  
  179.  
  180. ΓòÉΓòÉΓòÉ 10. Class Exercise (OOPS) ΓòÉΓòÉΓòÉ
  181.  
  182. o Identify each of the following as an Object or Method: 
  183.  
  184.    - printer 
  185.  
  186.    - add 
  187.  
  188.    - date 
  189.  
  190.    - getdate 
  191.  
  192.    - delete 
  193.  
  194.    - 74 
  195.  
  196. o Design an object called "Student" 
  197.  
  198.  
  199. ΓòÉΓòÉΓòÉ 11. Class Exercise (Application Scenario) ΓòÉΓòÉΓòÉ
  200.  
  201. A local bank wishes to allow merchants in a small shopping center on-line 
  202. verification of charge card purchases.  Merchants who are bank customers should 
  203. have the ability to download a set of their most active customers (with account 
  204. information) to a local database for verification.  A larger database will 
  205. serve the entire shopping center, and will contain account information for ALL 
  206. bank customers (note, the entire shopping center is on a local area network). 
  207. For customers who do NOT bank locally, the merchant can access a remote 
  208. verification center for credit card approvals.  The merchant has no way of 
  209. knowing where information for any particular customer will reside. 
  210.  
  211. o Set up the underlying program architecture for the merchant's credit-card 
  212.   verification system -- assume the entire shopping center is on a token-ring 
  213.   supported by an AS/400 as a database server 
  214.  
  215. o What are some technical concerns relating to: 
  216.  
  217.    - maintainance of local customer information 
  218.    - keeping the AS/400 database current 
  219.  
  220. o Be sure to STATE YOUR ASSUMPTIONS! 
  221.  
  222.  
  223. ΓòÉΓòÉΓòÉ <hidden> Data Encapsulation ΓòÉΓòÉΓòÉ
  224.  
  225. A CheckingAccount object ... 
  226.  
  227.  
  228. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  229.  
  230. An object is Data, and access to the Data 
  231.  
  232. Note:  Data is kept as the object's Instance Variables during run-time 
  233.  
  234. Data access is accomplished via operations called Methods 
  235.  
  236.  
  237. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  238.  
  239. Communication Between Objects 
  240.  
  241. o Via messages 
  242.  
  243.    - access data 
  244.  
  245.    - modify data 
  246.  
  247. o Methods send/receive (are invoked by) messages 
  248.  
  249. o Messages to which an object responds form its protocol 
  250.