Summary OOP

  • Published on
    20-Apr-2015

  • View
    69

  • Download
    3

Embed Size (px)

Transcript

<p> :OOP 1 :Thinking Object Oriented 2. ? " . 3. ? . 1. . 2. 4. ? Server/receiver 5. OOP ? " , " . , . 6. ? )?(behavior ) (instance . .integers/lists . , . 7. ) ?(class inheritance hierarchy ? . . 8. ) (override ? " " . . 9. ?process-state 01. ... 11. OOP ? OOP "" . , . OOP .</p> <p> " + . " . / + eliorar@bgu.ac.il</p> <p> 2: AbstracOon 1. ? . 2. : , , , . . : , . .. '. 3. )?(informaOon hiding . " // . 4. : , , , )(. , . . 5. :OOP 1. . 2. package . 3. . 4. . 5. . 6. . 6. Client , Server . 7. ? " , . . 8. ? , , / , ' " . 9. ) (composiOon ? Devision Into Parts</p> <p> " + . " . / + eliorar@bgu.ac.il</p> <p>01. SpecializaOon ? SpecializaOon Is-A . . , parts ,Has-A . . 11. ?paPerns . . 21. ? )(InformaOon Hiding , . InformaOon Hiding , , " . 31. ? . ) (EncapsulaOon , ) -(public , ) (private . , ) (data . )" .(import/export 41. ) ADT ( ? ADT : 1. . 2. " . 3. . 4. . InformaOon Hiding 3,2. . ) (. 51. ?ADT ? ADT /.ADT , ADT . ADT , .</p> <p> " + . " . / + eliorar@bgu.ac.il</p> <p> 3: Object-Oriented Design 1. ' : 1. )-(. 2. . 3. . 2. : 1. . . 2. , . 3. . 4. )?(scenario . 5. ?component component: component - . ) .(responsibiliOes - , .responsibiliOes - . 6. ?CRC CRC = Component ResponsibiliOes Collaborates - responsibiliOes . 7. ?What/Who - .what/who = What , = Who . 8. ? . -. 9. ? : , . 01. ? .</p> <p> " + . " . / + eliorar@bgu.ac.il</p> <p>11. ? (parnas (parnas principle 1. -) .component = (public 2. ) = (private 21. ? 1. )( . 2. . 3. . 4. . , . 31. ? . 41. ? . / , ), , ( .</p> <p> " + . " . / + eliorar@bgu.ac.il</p> <p> 4: Classes and Methods 1. class-declaraOon- ? (object-declaraOon (instanOaOon class-declaraOon- object-declaraOon / , . " . 2. ?Instance Variable = Instance Variable " ) (. 3. ? / ):(Behavior and state Behavior . " . State . " .Instance Variables 4. nal staOc ?java ? = Final . = StaOc ) (. . 5. ?public/private Public' . Private' . 6. ? ) (. 7. ?(accessors methods (gePers ? = GePer . gePers: 1. . 2. . 3. . 8. ?(Mutator (sePer = SePer . 9. ? 1. . 2. . 3. public .private 4. ), , '(. 5. ". 01. ?immutable data eld = Immutable data eld . " , . " + . " . / + eliorar@bgu.ac.il</p> <p>11. ?fully qualied name ) :(++C PlayingCard::Colors PlayingCard::color 21. ? . , , . " . 31. ?inner/nested class . java inner- ++C .nested , . Inner class java ) ( . Nested class ++C . ) (visibility ' ,Nested class . 41. . " , - . .</p> <p> " + . " . / + eliorar@bgu.ac.il</p> <p> 5: Messages, Instances and IniOalizaOon 1. ? 1. . 2. . 2. ? 1. The Message Receiver . 2. The message Selector )(. 3. . 3. small-talk ?C++/JAVA 1. . 2. ) receiver (. 3. . 4. ) (Message Selector , . . 4. ,StaOcally typed ?Dynamically typed :StaOcally typed - . - . - .receiver - .C++, C# ,Java :Dynamically typed - , . - . - . - .Small-Talk, Python, CLOS 5. " " ?StaOcally typed ?Dynamically typed , , " ", . 6. - ) this self (small-talk? This .receiver , . 7. ) (stack )?(heap , . - .AF , - .AF 8. ? 1. ) ++C (. 2. garbage-collector .</p> <p> " + . " . / + eliorar@bgu.ac.il</p> <p>9. garbage-collecOon? 1. . 2. . 3. . 01. ? , . 11. destructor? Destructor , . , .delete 6: The Eight Queen Puzzle 1. ?The Eight Queen Puzzle 8 " . 2. OOP ? , . , , . , . , ,OOP . , , . 3. generate-test ? , .</p> <p> " + . " . / + eliorar@bgu.ac.il</p> <p> 8: Inheritance and SubsOtuOon 1. ? ? . 2. is-a? A - B" ,A is-a B , . 3. ? : 1. ) (reuse of code , . 2. ) (reuse of concept " , , . : ) (. 4. ) ?(subsOtuOon ? B )( A B .A : 1. . 2. )" ( . 3. , . 5. ? ? . , , . 6. : :subclassing for = (SpecializaAon (sub-typing , . : window ), , '( TextEditWindow , . = SpecicaAon . ): (java event listeners = ConstrucAon is-a List ,set" .subsOtuOon = GeneralizaAon . colorWindow Black&amp;White .Window = Extension GeneralizaOon/ , Extension . StringSet Set . = LimitaAon ) (. " .subsOtuOon = Variance . - , ', . ) - " + . " . / + eliorar@bgu.ac.il</p> <p>.(subclassing for specializaOon : 571 . 7. subclassing for construcOon ? . ) (. 8. subclassing for limitaOon ? . ) (. 9. )?(so@ware reuse , . 01. )?(consistency of interface " . 11. ?rapid prototyping , . 21. )?(informaOon hiding , . 31. )?(anonymous class 1. . 2. , . 41. ) (execuOon Ome " ? ? execuOon Ome" , .execuOon Ome ,run-Ome .execuOon Ome</p> <p> " + . " . / + eliorar@bgu.ac.il</p> <p> 11: StaOc and Dynamic Behavior 1. , ) (staOc? StaOc " ". 2. dynamic? Dynamic " ". 3. staOcally typed ?dynamically typed . , , . 4. ) (type inference ? ,ML . , ML .staOcally typed 5. : . . . 6. ? ? ? = . = )" (. , . 7. " ? " " , . 8. ?down casOng Down casOng . 9. ) (staOcally bound, ? , " ) (, . </p> <p> " + . " . / + eliorar@bgu.ac.il</p> <p> 21: ImplicaOons of SubsOtuOon 1. ? , , " . , . 2. ? 1. base class . 2. . 3. , . 3. ++C , ) (slicing? 4. OOP ? OOP . . 5. , ? . 6. pointer semanOcs ?copy semanOcs = Pointer semanOcs B A B ,A Copy SemanOcs - B A .A 7. ) (deep copy )?(shallow copy , , . , . 8. ) (object idenOty )?(object equality = IdenOty ) ( . = Equality .</p> <p> " + . " . / + eliorar@bgu.ac.il</p> <p> 31: MulOple Inheritance 1. ?is-a - A B A is-a B A . A is-a B A can be .viewed as-a B 2. - ) (ambiguity name ? - ? - C A B- A- B .C ? : 1. , ()A::func .()B::func 2. overloading . 3. C A .B 3. - - CLOS ?++C ? - ?java name ambiguity java . ? - ? " ", ) ( ? cardDeck graphicalObject graphicalCardDeck , ,InputOutputStream .buer ) (inner class java ? Inner class , . 4. 5. 6.</p> <p>7.</p> <p>8. " ?inner class ,subsOtuOon A B C ,D B D , A B ) D (. .</p> <p> " + . " . / + eliorar@bgu.ac.il</p> <p> 41: Polymorphism and So@ware Reuse 1. ?polymorphism Poly= many, morpheus = form 2. ?ad-hoc polymorphism Ad-hoc polymorphism ,overloading . 3. overloading - ?overriding ? overriding overloading . overloading . 4. ) (polymorphic variable ? , . 5. ' ) (generic funcOon ++C ? ' " , " . 6. composiOon ? ComposiOon . " ) ,(list . 7. ? " . 8. ) (composiOon ? ? ComposiOon " . " . 9. ? 01. ?</p> <p> " + . " . / + eliorar@bgu.ac.il</p> <p> 51: Overloading 1. )?(overloaded , . 2. ?type signature = Type signature , , . 3. ?scope Scope . 4. )? (overloading = Overloading based on scopes scope -. = overloading based on type signatures . 5. " ? . 6. ? ? ,scope , . 7. ++C , ?streams : ) ostream &amp; operator </p>