1 / 9

David Evans cs.virginia/~evans

Explore the importance of thinking and programming in today's lecture on object-oriented languages. Learn about web browser module design and code implementation. Discover the advantages of your design and language choice.

fhalvorson
Download Presentation

David Evans cs.virginia/~evans

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. Lecture 10: Using Object-Oriented Languages You can't think seriously about thinking without thinking about thinking about something. Seymour Papert Today’s corollary: You can’t think seriously about programming, without thinking about programming something. Start working in groups as described in the manifest. David Evans http://www.cs.virginia.edu/~evans CS655: Programming Languages University of Virginia Computer Science

  2. Menu • Today’s Task • Position Paper Hints • Contravariance, covariance and ski-team room-mates • Language team sales pitches University of Virginia CS 655

  3. Today’s Task • Show a high-level module design for your web browser • Depending on the language, this might have subclassing, subtyping and uses relationships. • Show a concrete code excerpt for redisplaying all the elements • Argue that your design (in conjunction with your implementation language) is superior to alternatives • Assume all languages have equally good development tools, well-trained programmers, etc. University of Virginia CS 655

  4. Position Paper Hints • Average on Position Paper 2 = 0.89 (12 out of 25 were 1.0 or above) • Make sure to answer the assigned question • If it isn’t clear, ask • If you make general statements, back them up with real examples • Don’t turn in a laundry list – select and organize the important things • Be resourceful, cite your resources • Things in your references list should be cited in your text (e.g., Bounds checking can be added to C [Wahbe93] ...) University of Virginia CS 655

  5. Contra/Co-Variance Athlete How can Girl override set_roomate? Covariance: set_roommate (Girl) set_roommate (Boy) Contravariance: set_roommate (Athlete) Novariance: set_roommate (Skier) (Eiffel) Skier set_roommate (Skier) (Sather) (C++ - but changing?, Java) Boy Girl Problem: s: skier; g: girl; b: boy; s := g; ... s.set_roommate (b); University of Virginia CS 655

  6. What’s wrong with Meyer’s Rule? • Disallow polymorphic catcalls: s.f (t) where some subtype of type of s hides f or changes covariantly type of parameters of f. • Violates useful notion of subtyping: adding a new subtype breaks existing programs! University of Virginia CS 655

  7. What does C++ do? • Can add covariant methods in subtype, but they overload the original method, instead of overriding it! • Example: class skier { virtual void set_roommate (class skier *); } class girl : public skier { void set_roommate (class girl *); // overloads! } // class boy similar skier *s; girl *g; boy *b; s = g; s->set_roommate (b); // No type error – calls skier::set_roommate! g->set_roommate (b); // Some compilers complain (but shouldn’t?) Good explanation is worth 1 position paper point. University of Virginia CS 655

  8. Some C++ Facts • 1996 Draft Standard is 680 pages long • 50x more complex than Algol60! Is this progress? • Current open issues list of Core Language Issues contains 173 issues • Compare to Knuth’s 9 ambiguities in Algol 60 • Current open issues list for standard library (Revision 12) is 59 pages • Good luck! University of Virginia CS 655

  9. Browser Design Pitches • Next time: John Viega on Automated Delegation solution to Multiple Inheritance • Think of and send me one good question. • Accomplish something interesting to talk about in your project meetings. University of Virginia CS 655

More Related