Nathanael Schärli (SCG, University of Bern) and Andrew P. Black (CSE, Oregon Health & Science University) Nathanael Schärli (SCG, University of Bern) and.

Slides:



Advertisements
Similar presentations
Object Oriented Programming
Advertisements

Basics of Inheritance CS 5010 Program Design Paradigms "Bootcamp" Lesson 12.1 © Mitchell Wand, This work is licensed under a Creative Commons.
Object Oriented Programming
Matt Klein. Decorator Pattern  Intent  Attach Additional responsibilities to an object by dynamically. Decorators provide a flexible alternative to.
1 Chapter 6: Extending classes and Inheritance. 2 Basics of Inheritance One of the basic objectives of Inheritance is code reuse If you want to extend.
Week 8 Recap CSE 115 Spring Composite Revisited Once we create a composite object, it can itself refer to composites. Once we create a composite.
David Evans CS200: Computer Science University of Virginia Computer Science Lecture 23: Inheritance.
Language Issues for Inheritance CS 5010 Program Design Paradigms "Bootcamp" Lesson 12.3 © Mitchell Wand, This work is licensed under a Creative.
Chapter 10: Introduction to Inheritance
Stéphane Ducasse«ChapterNr».1 Selected Design Patterns Design Patterns are recurrent solutions to design problems They are pros and cons We already saw:
Object Oriented System Development with VB .NET
Dynamic Object-Oriented Programming with Smalltalk 1. Introduction Prof. O. Nierstrasz Summer Semester 2006.
Advanced Object-Oriented Programming Features
C# Programming: From Problem Analysis to Program Design1 Advanced Object-Oriented Programming Features C# Programming: From Problem Analysis to Program.
Visual Basic Introduction IDS 306 from Shelly, Cashman & Repede Microsoft Visual Basic 5: Complete Concepts and Techniques.
Chapter 10 Classes Continued
(c) University of Washington03-1 CSC 143 Java Inheritance Reading: Ch. 10.
Starting Chapter 4 Starting. 1 Course Outline* Covered in first half until Dr. Li takes over. JAVA and OO: Review what is Object Oriented Programming.
Design Patterns.
OOPs Object oriented programming. Based on ADT principles  Representation of type and operations in a single unit  Available for other units to create.
LECTURE 38: REFACTORING CSC 395 – Software Engineering.
IT253: Computer Organization
Using Inheritance to Share Implementations CS 5010 Program Design Paradigms "Bootcamp" Lesson 12.1 © Mitchell Wand, This work is licensed under.
1 Computer Science 340 Software Design & Testing Inheritance.
Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Object Oriented.
Chapter 8 Object Design Reuse and Patterns. Object Design Object design is the process of adding details to the requirements analysis and making implementation.
Refactoring Deciding what to make a superclass or interface is difficult. Some of these refactorings are helpful. Some research items include Inheritance.
Chapter 38 Persistence Framework with Patterns 1CS6359 Fall 2011 John Cole.
UML Class Diagram Trisha Cummings. What we will be covering What is a Class Diagram? Essential Elements of a UML Class Diagram UML Packages Logical Distribution.
CIS 112 Exam Review. Exam Content 100 questions valued at 1 point each 100 questions valued at 1 point each 100 points total 100 points total 10 each.
Object Oriented Software Development
Design Patterns -- Omkar. Introduction  When do we use design patterns  Uses of design patterns  Classification of design patterns  Creational design.
 All calls to method toString and earnings are resolved at execution time, based on the type of the object to which currentEmployee refers.  Known as.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
CS2110: SW Development Methods Inheritance in OO and in Java Part 2: Topics: Forms of inheritance Interfaces in Java.
CSCI-383 Object-Oriented Programming & Design Lecture 10.
Abstract Classes and Interfaces 5-Dec-15. Abstract methods You can declare an object without defining it: Person p; Similarly, you can declare a method.
Inheritance Revisited Other Issues. Multiple Inheritance Also called combination--not permitted in Java, but is used in C++ Also called combination--not.
M1G Introduction to Programming 2 5. Completing the program.
OOPs Object oriented programming. Abstract data types  Representationof type and operations in a single unit  Available for other units to create variables.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
JAVA Programming (Session 4) “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
Topics Inheritance introduction
SEG 4110 – Advanced Software Design and Reengineering Topic T Introduction to Refactoring.
The Strategy Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
Java Programming, Second Edition Chapter Twelve Advanced Inheritance Concepts.
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)
ITEC0724 Modern Related Technology on Mobile Devices Lecture Notes #2 1.
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
POLYMORPHISM Chapter 6. Chapter Polymorphism  Polymorphism concept  Abstract classes and methods  Method overriding  Concrete sub classes and.
Stéphane Ducasse 1 Abstract Classes.
(c) University of Washington05-1 CSC 143 Java Abstract Classes and Frameworks Reading: Ch. 11.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
C++ General Characteristics: - Mixed typing system - Constructors and destructors - Elaborate access controls to class entities.
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.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
 The word static is used to declare either a ________ variable or method.  Why do we use statics?  What is Polymorphism? class In general, we use a.
Smalltalk Meta-Programming Programming Languages HUJI 2010 Yardena Meymann.
Inheritance.
Sections Inheritance and Abstract Classes
Class 22: Inheritance CS150: Computer Science University of Virginia
Chapter 11 Object-Oriented Design
PRINCIPALES OF OBJECT ORIENTED PROGRAMMING
Lecture 21: Inheritance CS200: Computer Science University of Virginia
Advanced Java Topics Chapter 9
Decorator Pattern Richard Gesick.
Presentation transcript:

Nathanael Schärli (SCG, University of Bern) and Andrew P. Black (CSE, Oregon Health & Science University) Nathanael Schärli (SCG, University of Bern) and Andrew P. Black (CSE, Oregon Health & Science University) A Browser for Incremental Programming me

2 What we do in Smalltalk! One of the Extreme Programming (XP) practices Characterized by some patterns of work that should be familiar to you: What we do in Smalltalk! One of the Extreme Programming (XP) practices Characterized by some patterns of work that should be familiar to you: What is Incremental Programming?

3 Programming with limited knowledge Working in multiple contexts Refactoring Testing Understanding how classes collaborate Understanding what is still missing Programming with limited knowledge Working in multiple contexts Refactoring Testing Understanding how classes collaborate Understanding what is still missing Incremental work patterns – Generic protocols, absence of declarations – Multiple windows, tiling browsers – ? – Refactoring Browser – SUnit

4 Provide information about completeness of classes and collaborations between classes that is  statically computed,  always accessible, and  always up-to-date Why not? This information is in the code  My PowerBook is 50 times faster than a Dorado Provide information about completeness of classes and collaborations between classes that is  statically computed,  always accessible, and  always up-to-date Why not? This information is in the code  My PowerBook is 50 times faster than a Dorado How should we support Incremental Programming?

5 How to present it? categorization of methods by the browser, based on their characteristics; always up-to-date Virtual Categories

6 -requires-  all messages sent to this class for which there is no method defined or inherited -supplies-  all messages required by some other class for which methods are provided in this class -overrides-  methods defined in this class that override inherited methods - sending super -  methods that perform super sends -requires-  all messages sent to this class for which there is no method defined or inherited -supplies-  all messages required by some other class for which methods are provided in this class -overrides-  methods defined in this class that override inherited methods - sending super -  methods that perform super sends Four Categories:

7 supplies & overrides

8 Extended Example/Demonstration DemoList DemoEmptyList DemoConsList printOn: size printOn: size head rest do: head rest do: head rest do: head rest do: isEmpty Creating a new sub-tree of classes

9 Feedback from the browser helps us find:  which methods are “core” and which are “support”  how the sub- and superclasses depend on each other When extending code, the browser helps avoid:  introducing inter -level errors  accidentally incomplete classes Feedback from the browser helps us find:  which methods are “core” and which are “support”  how the sub- and superclasses depend on each other When extending code, the browser helps avoid:  introducing inter -level errors  accidentally incomplete classes Understanding and Modifying Existing Hierarchies

10 A common pattern used to increase reuse in a data type implementation [Black ECOOP inh wk 2002]  e.g., the abstract superclass Collection defines 110 support methods they don’t access the state of any collection directly instead, they depend on 4 core methods – add:, atRandom:, do: and remove:ifAbsent:  3 are defined as self subclassResponsibility  atRandom: is not defined at all The browser finds these 4 required methods amongst the 110! A common pattern used to increase reuse in a data type implementation [Black ECOOP inh wk 2002]  e.g., the abstract superclass Collection defines 110 support methods they don’t access the state of any collection directly instead, they depend on 4 core methods – add:, atRandom:, do: and remove:ifAbsent:  3 are defined as self subclassResponsibility  atRandom: is not defined at all The browser finds these 4 required methods amongst the 110! The Core/Support Split

11 When we look at a subclass of Collection, e.g., Bag, we can distinguish:  the 4 supplied methods,  10 methods that override the inherited methods, either to disable them or to improve their efficiency, and  7 additional methods that widen the interface of Bag beyond that of Collection When we look at a subclass of Collection, e.g., Bag, we can distinguish:  the 4 supplied methods,  10 methods that override the inherited methods, either to disable them or to improve their efficiency, and  7 additional methods that widen the interface of Bag beyond that of Collection The Core/Support Split (2)

12 The browser tells us some surprising things about Squeak’s core classes:  Fraction is abstract it implements the support method printOn:, whereas it should implement the core method printOn:Base :  Bitmap is abstract the programmer sends an error message primitiveFail, which he forgot to define  Debugger, CharacterSet, Morph (and nearly all of its subclasses): all are abstract The browser tells us some surprising things about Squeak’s core classes:  Fraction is abstract it implements the support method printOn:, whereas it should implement the core method printOn:Base :  Bitmap is abstract the programmer sends an error message primitiveFail, which he forgot to define  Debugger, CharacterSet, Morph (and nearly all of its subclasses): all are abstract Accidentally Abstract Classes

13 Why are these errors present in a code base that has been used by thousands of users for many years?  It is not because a bad programmer wrote BitMap It is because even good programmers will make mistakes unless they have good tools Why are these errors present in a code base that has been used by thousands of users for many years?  It is not because a bad programmer wrote BitMap It is because even good programmers will make mistakes unless they have good tools Accidentally Abstract Classes (2)

14 - sending super - is easy  look for the bytecode for super sends -overrides- is easy  compare this class’s selectors with its superclass’s protocol -supplies- is easy once one knows requires  compare this class’s selectors with the requires set of other classes -requires- is most definitely not easy  implementing requires in real-time required a lot of careful thinking and more careful programming! - sending super - is easy  look for the bytecode for super sends -overrides- is easy  compare this class’s selectors with its superclass’s protocol -supplies- is easy once one knows requires  compare this class’s selectors with the requires set of other classes -requires- is most definitely not easy  implementing requires in real-time required a lot of careful thinking and more careful programming! Implementation

15 Pseudocode: ° Behavior >> requiresself reachableMethods selfMessages difference: (self allReallyImplementedSelectors) Pseudocode: ° Behavior >> requiresself reachableMethods selfMessages difference: (self allReallyImplementedSelectors) What’s in the requires category? We had to invent and formalize a definition of reachability allSelectors \ those not really implemented ( subclass- Responsibility, shouldNotImplement, requirement, etc.) Cannot infer this from bytecode.

16 Recognizing self-sends requires a full parse of the method text A change in, say, Object, might change the required methods of every class in the system! Squeak images contain > methods We decided that we needed to cache the self- sends for every method when it is compiled Recognizing self-sends requires a full parse of the method text A change in, say, Object, might change the required methods of every class in the system! Squeak images contain > methods We decided that we needed to cache the self- sends for every method when it is compiled Recognizing self-sends

17 Even with these caches for self- and super sends, the first implementation took over 3 minutes to ascertain the required methods of a class! A problem of scale

18 The caches should be arranged “backwards”  for each message, cache the methods that self-send it We don’t need to know the requires set, all we need to know is whether it is empty  Does a subclass override all of the methods that self-send a message required by the superclass? if not, we immediately know that it is also required in the subclass The caches should be arranged “backwards”  for each message, cache the methods that self-send it We don’t need to know the requires set, all we need to know is whether it is empty  Does a subclass override all of the methods that self-send a message required by the superclass? if not, we immediately know that it is also required in the subclass Two key insights

19 is far too complex to put on a slide  that’s what the paper is for! Computing the required set now takes less than 100 ms — fast enough to provide “real- time” feedback is far too complex to put on a slide  that’s what the paper is for! Computing the required set now takes less than 100 ms — fast enough to provide “real- time” feedback The Complete Algorithm…

20 To do lists  Trellis’s “grass catcher” was also the product of changing a single method  More commonly, as with Eclipse’s “Tasks” window, to do lists are updated only on global recompilation. Browser extensions  decoration of names to indicate local properties such as overrides or sends to super, e.g., in VisualWorks  Star Browser allows the definition of intentional classifications that are recomputed when necessary To do lists  Trellis’s “grass catcher” was also the product of changing a single method  More commonly, as with Eclipse’s “Tasks” window, to do lists are updated only on global recompilation. Browser extensions  decoration of names to indicate local properties such as overrides or sends to super, e.g., in VisualWorks  Star Browser allows the definition of intentional classifications that are recomputed when necessary Related Work

21 Other visualizations of the self-send information  e.g., Blueprint-like diagrams Two directions for extension:  Help in understanding other kinds of collaboration e.g., delegation, aggregation, Mudpie’s package dependencies  A pluggable browser framework what are the key features? Other visualizations of the self-send information  e.g., Blueprint-like diagrams Two directions for extension:  Help in understanding other kinds of collaboration e.g., delegation, aggregation, Mudpie’s package dependencies  A pluggable browser framework what are the key features? Future Work

22 The Browser is Feasible  with careful design and implementation, it is feasible to provide real-time feedback even for global properties such as required methods The Browser is Useful  Simplifies Intentional Programming  Makes it easier to understanding existing classes  Clarifies the relationship between sub- and superclasses  Exposes many bugs in existing code The Browser is Feasible  with careful design and implementation, it is feasible to provide real-time feedback even for global properties such as required methods The Browser is Useful  Simplifies Intentional Programming  Makes it easier to understanding existing classes  Clarifies the relationship between sub- and superclasses  Exposes many bugs in existing code Conclusion

23 Questions!

24 Which methods are reachable?

25 fastenVerySecurely| temp |self hook. temp := self temp button. self class new clipTo: self Which messages are self- sent? This is a self-send, and we recognize it This is a self-send, but we don’t recognize it