DOC PREVIEW
UW CSE 341 - Extensibility in OO and FP

This preview shows page 1 out of 4 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 4 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

'&$%CSE 341:Programming LanguagesHal PerkinsSpring 2011Lecture 25— Extensibility in OO and FPHal Perkins CSE341 Spring 2011, Lecture 25 1'&$%One-of types and operations• Given a type with several variants/subtypes and severalfunctions/methods, there’s a 2D-grid of code you need:Int Negate Add MultevaltoStringhasZero• OO and FP just lay out the code differently!!!• Which is more convenient depends on what you’re doing andhow the variants/operations “fit together”• Often, tools let you view “the other dimension”• Opinion: Dimensional structure of code is greater than 2–3, sowe’ll never have exactly what we want in text.Hal Perkins CSE341 Spring 2011, Lecture 25 2'&$%ExtensibilityLife gets interesting if need to extend code w/o changing existingcode.• ML makes it easy to write new operations; Java does not• Java makes it easy to write new variants; ML does not• In ML the original code must plan for extensibility usingpolymorphism and function arguments• In Java the original code must plan for extensibility using“extra” abstract methods– (see “the visitor pattern” on your own)Hal Perkins CSE341 Spring 2011, Lecture 25 3'&$%UnextensibilityExtensibility is not all it’s cracked up to be:• Makes original code more difficult to change later• Makes code harder to reason about locally (e.g., dynamicdispatch or functions-as-arguments mean you never know whatcode might execute next)ML and Java have different defaults, but both let you decide whatto make extensible:• ML: Generally less extensible. Without a type constructor or afunction-argument, you limit what might happen (thanks toclosed recursion)• Java: Generally extensible by default. But you can declaremethods or classes final; arguably under-used.Hal Perkins CSE341 Spring 2011, Lecture 25


View Full Document

UW CSE 341 - Extensibility in OO and FP

Documents in this Course
Macros

Macros

6 pages

Macros

Macros

6 pages

Macros

Macros

3 pages

Mutation

Mutation

10 pages

Macros

Macros

17 pages

Racket

Racket

25 pages

Scheme

Scheme

9 pages

Macros

Macros

6 pages

Load more
Download Extensibility in OO and FP
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Extensibility in OO and FP and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Extensibility in OO and FP 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?