Java Layers Language Support for Stepwise Refinement Rich Cardone, IBM Research & UT at Austin Calvin Lin, University of Texas at Austin.

Slides:



Advertisements
Similar presentations
Object-Oriented Application Frameworks Much of the cost and effort stems from the continuous re- discovery and re-invention of core concepts and components.
Advertisements

Object-Oriented Programming Python. OO Paradigm - Review Three Characteristics of OO Languages –Inheritance It isn’t necessary to build every class from.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Feb. 23, 2004CS WPI1 CS 509 Design of Software Systems Lecture #5 Monday, Feb. 23, 2004.
Dept. of Computer Engineering, Amir-Kabir University 1 Design Patterns Dr. Noorhosseini Lecture 2.
Data Abstraction and Object- Oriented Programming CS351 – Programming Paradigms.
CS 2511 Fall  Abstraction Abstract class Interfaces  Encapsulation Access Specifiers Data Hiding  Inheritance  Polymorphism.
1 A Short Introduction to (Object-Oriented) Type Systems Kris De Volder.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 18 Object Database Management Systems.
Creational Patterns Making Objects The Smart Way Brent Ramerth Abstract Factory, Builder.
Copyright © 2002, Systems and Computer Engineering, Carleton University Intro.ppt * Object-Oriented Software Development Unit 1 Course.
Programming Languages and Paradigms Object-Oriented Programming.
Design Patterns.
Chapter 15 – Inheritance, Virtual Functions, and Polymorphism
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
OOPs Object oriented programming. Based on ADT principles  Representation of type and operations in a single unit  Available for other units to create.
(C) 2010 Pearson Education, Inc. All rights reserved. Java™ How to Program, 8/e.
Polymorphism, Inheritance Pt. 1 COMP 401, Fall 2014 Lecture 7 9/9/2014.
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
Composing Adaptive Software Authors Philip K. McKinley, Seyed Masoud Sadjadi, Eric P. Kasten, Betty H.C. Cheng Presented by Ana Rodriguez June 21, 2006.
CMSC 202 Generics. Nov Generalized Code One goal of OOP is to provide the ability to write reusable, generalized code. Polymorphic code using.
Programming Languages and Paradigms Object-Oriented Programming.
CSE 425: Object-Oriented Programming I Object-Oriented Programming A design method as well as a programming paradigm –For example, CRC cards, noun-verb.
 OOPLs  Help companies reduce complexity  Increase competition in open markets  Speeds up development  Improves maintenance, resusability, modifiability.
Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer.
Generative Programming. Automated Assembly Lines.
Introduction to Object Oriented Programming CMSC 331.
CSSE501 Object-Oriented Development. Chapter 11: Static and Dynamic Behavior  In this chapter we will examine the differences between static and dynamic.
Chapter 18 Object Database Management Systems. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Motivation for object.
Design Rules for Increasing Modularity with CaesarJ Carlos Eduardo Pontual Advisor: Paulo Borba 17/06/2010.
L11-12: Design Patterns Definition Iterator (L4: Inheritance)‏ Factory (L4: Inheritance)‏ Strategy (L5: Multiple Inheritance)‏ Composite (L6: Implementation.
Chapter 12 Support for Object oriented Programming.
1 CSC/ECE 517 Fall 2010 Lec. 3 Overview of Eclipse Lectures Lecture 2 “Lecture 0” Lecture 3 1.Overview 2.Installing and Running 3.Building and Running.
Introduction to Generics
Comparing Frameworks and Layered Refinement Richard Cardone and Calvin Lin Department of Computer Sciences University of Texas at Austin ICSE 2001.
Object-Oriented Modeling: Static Models. Object-Oriented Modeling Model the system as interacting objects Model the system as interacting objects Match.
Object-Oriented Programming Chapter Chapter
Object Oriented Programming
Object-Oriented Programming © 2013 Goodrich, Tamassia, Goldwasser1Object-Oriented Programming.
ISBN Object-Oriented Programming Chapter Chapter
Application development with Java Lecture 21. Inheritance Subclasses Overriding Object class.
Language and Compiler Support for Mixin Programming Richard Cardone Calvin Lin, Advisor Department of Computer Sciences University of Texas at Austin April.
Advanced Object-oriented Design Patterns Creational Design Patterns.
Chapter 18 Object Database Management Systems. Outline Motivation for object database management Object-oriented principles Architectures for object database.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Variations on Inheritance Object-Oriented Programming Spring
Presented by Ted Higgins, SQL Server DBA An Introduction to Object – Oriented Programming.
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
Testing in OO Environment The reasons for testing is not any different for any of the design and implementation methodologies, including OO methodology.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
Notices Assn 2 is due tomorrow, 7pm. Moodle quiz next week – written in the lab as before. Everything up to and including today’s lecture: Big Topics are.
Java Layers Language Support for Layered Refinement Rich Cardone Calvin Lin, Advisor Department of Computer Sciences University of Texas at Austin January.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Design Patterns: MORE Examples
Abstract Factory Pattern
Factory Patterns 1.
Types of Programming Languages
Abstract Factory Pattern
Designing Software for Ease of Extension and Contraction
Intent (Thanks to Jim Fawcett for the slides)
Object-oriented Design in Processing
Object-Oriented Programming
Objects and Aspects: What we’ve seen so far
Object-Oriented Programming
Object-oriented Design in Processing
Object-Oriented Programming
Object-oriented Design in Processing
Object-oriented Design in Processing
Presentation transcript:

Java Layers Language Support for Stepwise Refinement Rich Cardone, IBM Research & UT at Austin Calvin Lin, University of Texas at Austin

12/7/00Java Layers/RC,CL2 Problem Software development and maintenance is expensive Difficult Takes a long time Assemble applications from off-the-shelf components Mix and match features to create applications Plug and unplug components to change applications

12/7/00Java Layers/RC,CL3 Reuse is Key Separation of concerns One application feature per component Flexible composition

12/7/00Java Layers/RC,CL4 Presentation Overview Part I – Motivation Mixins Stepwise Refinement Drawbacks of Mixins Part II – Java Layers Java Layers Overview Two Language Features

12/7/00Java Layers/RC,CL5 An OO Problem CarBoxHouse Problem: Lockable code replicated 3 times Lockable Car Lockable Box Lockable House lock(), unlock()

12/7/00Java Layers/RC,CL6 An OO Solution Use same lockable code for all 3 classes Encapsulate lockable code in a class Subtype Car, Box, House with new class Mixin Class class Lockable extends T { lock(){…} unlock(){…} } [Bracha90]

12/7/00Java Layers/RC,CL7 Mixed-In Classes CarBoxHouse Lockable Lockable code reused 3 times Lockable

12/7/00Java Layers/RC,CL8 Mixins Types with parameterized supertypes Depend on type parameters More precisely: Parametric Polymorphism An OO mechanism for code reuse Apply same code to unrelated classes Work with single inheritance

12/7/00Java Layers/RC,CL9 Mixins & Software Components Question Can we use mixins to build applications out of reusable components? If so, then mixins must support: Separation of concerns Flexible composition Let’s look at an example application

12/7/00Java Layers/RC,CL10 Example: Music Server Variation can occur on many axes: Client interface {getSong, putSong, eraseCopyright, hideBritney, …} Server execution strategy {single threaded, thread-spawning, thread pool, …} Transport type Fault tolerance Server discovery …

12/7/00Java Layers/RC,CL11 Music Application Instances Base GetSong PutSong Simple Base GetSong PutSong NoBritney HideBritney Base EraseCopyright GetSong Thief ThreadSpawn GetSong leaf-types …

12/7/00Java Layers/RC,CL12 Application Assembly is Easy class Simple extends PutSong > {…} class NoBritney extends HideBritney >> {…} class Thief extends ThreadSpawn >> {…}

12/7/00Java Layers/RC,CL13 Base Class class Base { } static public class Server { void dispatchLoop(){for(;;) dispatch(readRequest());} void dispatch(Req req){errorUnknownReq(req);} … } static public class Client {…}

12/7/00Java Layers/RC,CL14 GetSong Mixin class GetSong extends T { static public class Client extends T.Client { void getSong(…){…} } static public class Server extends T.Server { void dispatch(Req req){ if (req.name.equals(“getSong”)) processGetSong(req); else super.dispatch(req); } … } constraintnested mixins

12/7/00Java Layers/RC,CL15 Other Mixins class EraseCopyright extends T { static public class Client extends T.Client { void eraseCopyright(…){…} } … } class ThreadSpawn extends T { static public class Server extends T.Server { void dispatchLoop(){…} } … }

12/7/00Java Layers/RC,CL16 Stepwise Program Refinement ClientServer Base EraseCopyright GetSong class Thief extends ThreadSpawn >> {…} ThreadSpawn Layers [Batory92]

12/7/00Java Layers/RC,CL17 Drawbacks of Mixins Superclass initialization Runtime efficiency Leaf-type references Composition validation Semantic validity Syntactic correctness

12/7/00Java Layers/RC,CL18 Recap Software components imply reuse Mixins reuse OO code Mixins build applications incrementally Stepwise program refinement Nested types encapsulate features Feature mixing and matching Mixins have usability & efficiency drawbacks

12/7/00Java Layers/RC,CL19 Part II – Java Layers Java Layers Overview Two JL Language Features Status Conclusion

12/7/00Java Layers/RC,CL20 Goal of Java Layers Increase software reuse to reduce development and maintenance costs Use layered, stepwise program refinement Encapsulate features in mixins classes Compose features through type instantiation

12/7/00Java Layers/RC,CL21 JL’s Foundation Java + Constrained Parametric Polymorphism (CPP) There are several proposals for adding CPP to Java [Agesen97, Bokowski98, Bracha98, Cartwright98, Myers97, Solorzano98] JL is a heterogeneous implementation of CPP Conventional syntax and semantics Parametric classes and interfaces Mixins

12/7/00Java Layers/RC,CL22 The JL Language JL is a parametric Java plus 4 features: Deep conformance Static virtual typing Semantic checking Constructor propagation All language extensions are designed to support stepwise refinement

12/7/00Java Layers/RC,CL23 JL Compiler Support Class hierarchy optimization Remove design-time layering from runtime code Inline calls to superclass methods w/same signature Collapse class hierarchy into a single class

12/7/00Java Layers/RC,CL24 The Need for Deep Conformance JL adds support for deep type checking Supertypes are checked for required nested types class Parent { class Inner {…} } class Child extends Parent {…} Question: Does Child contain a nested class named Inner? Answer: Maybe Java supports shallow type checking Interfaces and classes

12/7/00Java Layers/RC,CL25 Deep Conformance Deep Conformance supports stepwise refinement Enforces structural conformance at all nesting depths Subtypes can safely refer to nested types in their supertypes Feature composition is enhanced by added type precision

12/7/00Java Layers/RC,CL26 Deep Conformance Example class HideBritney extends deeply T { static public class Client extends T.Client {…} static public class Server extends T.Server {…} } HideBritney contains all the public nested types of T Compiler generates missing nested types if necessary Type parameter T binds to classes that: Extend Base Contain a nested Client class that extends Base.Client Contain a nested Server class that extends Base.Server

12/7/00Java Layers/RC,CL27 Deep Conformance Syntax Deeply modifier for implements and extends clauses Different meaning in constraint and inheritance clauses Operates on public nested types by default Propagate modifier for non-public nested types Enables selective deep type checking Use in parameterized and non-parameterized types

12/7/00Java Layers/RC,CL28 A Use of Virtual Types class Node {Node next;} class DoubleNode extends Node {DoubleNode prev;} class Node {virtual Node; Node next;} class DoubleNodeextends Node {typedef Node as DoubleNode; DoubleNode prev;} [Thorup97] In DoubleNode: next is type Node prev is type DoubleNode In DoubleNode: next is type DoubleNode prev is type DoubleNode

12/7/00Java Layers/RC,CL29 Virtual Types The automatic adaptation of types through inheritance. Virtual types change through subtyping A child class can change the type of its parent Benefits of Virtual Typing Greater type precision Better type checking Less manual typecasting Genericity (Beta)

12/7/00Java Layers/RC,CL30 JL’s This Virtual Type This pseudo-type is like the “type of this.” Static binding Used in parametric types only Bound at instantiation time Enhances JL’s expressiveness Allows the instantiated leaf-type to be expressed within the mixins being composed to define that leaf-type.

12/7/00Java Layers/RC,CL31 This Example Base GetSong Client- Factory PutSong class ClientFactory extends T deeply { static public class Client extends T.Client { static Client clientFactory() {return new Client();} } … } class ClientFactory extends T deeply { static public class Client extends T.Client { static This clientFactory() {return new This();} } … } leaf-type

12/7/00Java Layers/RC,CL32 Work Completed Implemented JL prototype Compared JL to OO Frameworks Reengineered Schmidt’s ACE ICSE 2001 paper

12/7/00Java Layers/RC,CL33 Future Work Develop new JL compiler Implement language described here Build a family of related applications Compare JL and OO approaches

12/7/00Java Layers/RC,CL34 Related Work GenVoca – Batory92-00, Smaragdakis98-99 Parametric Polymorphism – Agesen97, Bokowski98, Bracha90, Bracha98, Cartwright98, Myers97, Solorzano98 Virtual Types – Bruce97-98, Madsen89, Thorup97, Thorup99, Torgerson98 Semantic Checking – Batory95, Perry89-93 Programming Paradigms – Danforth98, Gamma94, Harrison93, Johnson91, Kiczales97, Schmidt98, Tarr99

12/7/00Java Layers/RC,CL35 Conclusion JL extends Java to improve reusability Promotes stepwise program refinement Assembles applications from reusable parts Builds on parametric polymorphism Adds a small number of language features Is this approach practical for application programming?

12/7/00Java Layers/RC,CL36 THE END Think Layers