1 / 9

Objectives

Objectives. Understand grammar of OOP Understand equivalent Java code Discuss different implementations of classes and objects. Class Declarations. Object Expressions. How do we do this in Java?. How do we implement this?. “idea”. Class Declarations. store class definitions. Class

gavin
Download Presentation

Objectives

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Objectives • Understand grammar of OOP • Understand equivalent Java code • Discuss different implementations of classes and objects

  2. Class Declarations

  3. Object Expressions

  4. How do we do this in Java?

  5. How do we implement this? “idea” Class Declarations store class definitions Class Representation Method Bodies Object Representation access classes and objects when executing program Program Body Base code is in 5-3.scm Implementation code is in 5-4-x.scm

  6. Interface to Classes Class Declarations elaborate-class-decls! (build repository of classes) Class Representation Method Bodies object->class-name (what kind of object am I?) super send new Object Representation find-method-and-apply (perform send) Program Body new-object (allocate new object)

  7. Class Representation (c3) Object Representation (o3) a-class-decl a-part a-part a-part class-name c3 class-name c3 class-name c2 class-name c1 super-name c2 fields fields fields field-ids x z method-decls 31 32 22 11 12 x z y x y a-method-decl u v method-name m1 method-ids method-body exp Simple Implementation 5.4.1 object is list of class-name / fields “parts” directly from grammar How do we implement: (elaborate-class-decls! c-decls) (object->class-name o3_rep) (find-method-and-apply ‘m1 ‘c3 o3_rep ‘(7 8)) (new-object ‘c3)

  8. a-method-decl method-name m1 method-ids method-body exp Flatten Object Fields 5.4.2 directly from grammar Object Representation (o3) Class Representation (c3) a-part a-class-decl class-name c3 class-name c3 fields search from right super-name c2 field-ids x z 11 12 22 31 32 method-decls x y y x z c1 c2 c3 u v How do we implement: (elaborate-class-decls! c-decls) (object->class-name o3_rep) (find-method-and-apply ‘m1 ‘c3 o3_rep ‘(7 8)) (new-object ‘c3)

  9. a-method method-decl super-name c2 a-method-decl field-ids method-name m1 u v method-ids x y y x z method-body exp Flatten Class Fields 5.4.3 Class Representation (c3) a-class class-name c3 super-name c2 field-length 5 field-ids x y y x z methods Object Representation (o3) How do we implement: (elaborate-class-decls! c-decls) (object->class-name o3_rep) (find-method-and-apply ‘m1 ‘c3 o3_rep ‘(7 8)) (new-object ‘c3) a-part class-name c3 fields 11 12 22 31 32 x y y x z 5.4.4 flattens class methods c1 c2 c3

More Related