Class 16: Concurrency Rules

Slides:



Advertisements
Similar presentations
Cs2220: Engineering Software Class 10: Generic Datatypes Fall 2010 University of Virginia David Evans.
Advertisements

David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 13: Concurring Concurrently.
Cs2220: Engineering Software Class 4: Specifying Procedures Fall 2010 University of Virginia David Evans.
Class 20: Verifying Bytecodes Fall 2010 UVa David Evans cs2220: Engineering Software Image: Joseph Featherston.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 16: Concurrent Programming.
March Ron McFadyen1 Composite Used to compose objects into tree structures to represent part-whole hierarchies Composite lets clients treat.
1 Generics Fall 2005 OOPD John Anthony. 2John J. Anthony Object Oriented Programming & Design Remember the Container Problem? ? You know the color of.
CS 2511 Fall Features of Object Oriented Technology  Abstraction Abstract class Interfaces  Encapsulation Access Specifiers Data Hiding  Inheritance.
Yixin Sun Class 17: Concurrency and OOP Fall 2010 UVa David Evans cs2220: Engineering Software.
Week 7 - Wednesday.  What did we talk about last time?  Recursive running time  Master Theorem  Introduction to trees.
CSCI-383 Object-Oriented Programming & Design Lecture 15.
CSSE501 Object-Oriented Development
CS-2851 Dr. Mark L. Hornick 1 Tree Maps and Tree Sets The JCF Binary Tree classes.
CS 206 Introduction to Computer Science II 09 / 30 / 2009 Instructor: Michael Eckmann.
Principles of Computer Programming (using Java) Review Haidong Xue Summer 2011, at GSU.
Cs2220: Engineering Software Class 11: Subtyping and Inheritance Fall 2010 University of Virginia David Evans.
Binary search trees. What’s on the menu? ADT DictionaryBST & Algorithms SimulatorComplexity.
Min Chen School of Computer Science and Engineering Seoul National University Data Structure: Chapter 7.
Cs2220: Engineering Software Class 8: Implementing Data Abstractions Fall 2010 University of Virginia David Evans.
Thought for the Day “To become truly great, one has to stand with people, not above them.” – Charles de Montesquieu.
1 Abstraction  Identify important aspects and ignore the details  Permeates software development programming languages are abstractions built on hardware.
Cs205: engineering software university of virginia fall 2006 Data Abstraction David Evans
Class 14: Object-Oriented Programming Fall 2010 University of Virginia David Evans cs2220: Engineering Software.
09-1 Queues and List-Based ADT Implementations Problem Set: PS3 due Wednesday, March 7 Wellesley College CS230 Lecture 09 Monday, February 26 Handout #18.
Cs2220: Engineering Software Class 6: Defensive Programming Fall 2010 University of Virginia David Evans.
Binary Search Trees Binary Search Trees (BST)  the tree from the previous slide is a special kind of binary tree called a binary.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 12: Subtyping Rules What’s the.
Mohammed Al-Dhelaan CSci 253 Object Oriented Design Instructor: Brad Taylor 06/02/2009 Factory Method Pattern.
Fall 2010 UVa David Evans cs2220: Engineering Software Class 27: Exam 2.
Cs205: engineering software university of virginia fall 2006 David Evans Substitution Principle.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 14: Substitution Principle.
CS 61B Data Structures and Programming Methodology July 2, 2008 David Sun.
Cs2220: Engineering Software Class 3: Java Semantics Fall 2010 University of Virginia David Evans.
Polymorphism Liskov 8. Outline equals() Revisiting Liskov’s mutable vs. not rule Polymorphism Uniform methods for different types “easy” polymorphism.
Cs205: engineering software university of virginia fall 2006 Subtyping and Inheritance David Evans Quiz Friday: classes through.
CS 206 Introduction to Computer Science II 10 / 02 / 2009 Instructor: Michael Eckmann.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 9: Designing Exceptionally.
Polymorphism SWE 619. Outline equals() Revisiting Liskov’s mutable vs. not rule Polymorphism Uniform methods for different types “easy” polymorphism Element.
CSSE501 Object-Oriented Development. Chapter 10: Subclasses and Subtypes  In this chapter we will explore the relationships between the two concepts.
Iteration Abstraction SWE Software Construction Fall 2009.
Cs2220: Engineering Software Class 12: Substitution Principle Fall 2010 University of Virginia David Evans.
Cs2220: Engineering Software Class 13: Behavioral Subtyping Fall 2010 University of Virginia David Evans.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 10: Programming Exceptionally.
David Evans CS201j: Engineering Software University of Virginia Computer Science Lecture 11: Subtyping and Inheritance.
Cs205: engineering software university of virginia fall 2006 Programming Exceptionally David Evans
Problem of the Day  Can you move exactly one glass to arrange the glasses containing orange juice to be next to one another?
David Evans CS201J: Engineering Software University of Virginia Computer Science Lecture 7: A Tale of Two Graphs (and.
David Evans CS201J: Engineering Software University of Virginia Computer Science Lecture 5: Implementing Data Abstractions.
CSCI 383 Object-Oriented Programming & Design Lecture 15 Martin van Bommel.
Trees.
Threaded Trees Binary trees have a lot of wasted space: the leaf nodes each have 2 null pointers We can use these pointers to help us in inorder traversals.
Depict the Tree Structure in a picture
Subtyping Rules David Evans cs205: engineering software BlackBear
Lecture 15: Concurring Concurrently CS201j: Engineering Software
Concurring Concurrently
Node Removal From BST Source:
null, true, and false are also reserved.
Conditional Statements
Tree A tree is a data structure in which each node is comprised of some data as well as node pointers to child nodes
Trees.
Instructor: Alexander Stoytchev
Data Abstraction David Evans cs205: engineering software
Lecture 7: A Tale of Two Graphs CS201j: Engineering Software
Lecture 4: Data Abstraction CS201j: Engineering Software
Instructor: Alexander Stoytchev
Instructor: Alexander Stoytchev
Lecture 13: Subtyping Rules Killer Bear Climber
Subtype Substitution Principle
Reasoning about Data Abstractions
Binary Tree Iterators Tree Traversals: preorder, inorder, postorder
Presentation transcript:

Class 16: Concurrency Rules cs2220: Engineering Software Class 16: Concurrency Rules Fall 2010 UVa David Evans Picture by Jonathan Dilorenzo

Menu PS4 Concurrency Object-Oriented Programming PS5 Designs [Throughout the Day] 1. Blanton, James Kalish, Michael 2. Borja, Joseph Oh, Uyn Noh, Brian 3. Brown, Jeremy Hearn, Charles 4. Chen, Jiamin Sparkman, Elisabeth Sun, Yixin 5. Dewey-Vogt, Michael Lopez, Erik 6. Dilorenzo, Jonathan Featherston, Joseph 7. Dollhopf, Niklaus Marion, John 8. Herder, Samuel Wallace, Alexander

Substitution Principle public class Tree { public Tree getChild (int n) // REQUIRES: 0 <= n < children.length // EFFECTS: Returns the Tree that is the nth leftmost child // of this. NOTE: the rep is exposed! public class BinaryTree extends Tree { // OVERVIEW: A BinaryTree is a mutable tree where the nodes are // int values and each node has zero, one or two children. @Override public BinaryTree getChild (int n) // REQUIRES: 0 <= n < 2 // EFFECTS: If this has at least n children, returns a copy of the // BinaryTree that is the nth leftmost child of this. Otherwise, // returns null. Does preTree imply preBinaryTree?

Substitution Principle public class Tree { public Tree getChild (int n) // REQUIRES: 0 <= n < children.length // EFFECTS: Returns the Tree that is the nth leftmost child // of this. NOTE: the rep is exposed! public class BinaryTree extends Tree { // OVERVIEW: A BinaryTree is a mutable tree where the nodes are // int values and each node has zero, one or two children. @Override public BinaryTree getChild (int n) // REQUIRES: 0 <= n < 2 // EFFECTS: If this has at least n children, returns a copy of the // BinaryTree that is the nth leftmost child of this. Otherwise, // returns null. Does 0 <= n < children.length imply 0 <= n < 2? When children.length <= 2, yes!

Does postBinaryTree imply postTree? public class Tree { public Tree getChild (int n) // REQUIRES: 0 <= n < children.length // EFFECTS: Returns the Tree that is the nth leftmost child // of this. NOTE: the rep is exposed! public class BinaryTree extends Tree { // OVERVIEW: A BinaryTree is a mutable tree where the nodes are // int values and each node has zero, one or two children. @Override public BinaryTree getChild (int n) // REQUIRES: 0 <= n < 2 // EFFECTS: If this has at least n children, returns a copy of the // BinaryTree that is the nth leftmost child of this. Otherwise, // returns null. Does postBinaryTree imply postTree?

Code that “breaks” with subtype: public class Tree { public Tree getChild (int n) // REQUIRES: 0 <= n < children.length // EFFECTS: Returns the Tree that is the nth leftmost child // of this. NOTE: the rep is exposed! public class BinaryTree extends Tree { // OVERVIEW: A BinaryTree is a mutable tree where the nodes are // int values and each node has zero, one or two children. @Override public BinaryTree getChild (int n) // REQUIRES: 0 <= n < 2 // EFFECTS: If this has at least n children, returns a copy of the // BinaryTree that is the nth leftmost child of this. Otherwise, // returns null. Code that “breaks” with subtype: Tree b1 = t.getChild(0); Tree b2 = t.getChild(0); assert b1 == b2;

PS5 Designs [Throughout the Day] 1. Blanton, James Kalish, Michael 2. Borja, Joseph Oh, Uyn Noh, Brian 3. Brown, Jeremy Hearn, Charles 4. Chen, Jiamin Sparkman, Elisabeth Sun, Yixin 5. Dewey-Vogt, Michael Lopez, Erik 6. Dilorenzo, Jonathan Featherston, Joseph 7. Dollhopf, Niklaus Marion, John 8. Herder, Samuel Wallace, Alexander

Parameterized Filters Object Filter MultiFilter PointFilter BlurFilter AverageFilter NegativeFilter Purple: abstract classes

ParameterizedBlurFilter Option 1: Filter subtype MultiFilter ParameterizedFilter PointFilter BlurFilter ParameterizedBlurFilter AverageFilter NegativeFilter Filter ParameterizedFilter Option 2: public int getParameter(); public abstract boolean hasParameter(); MultiFilter PointFilter BlurFilter AverageFilter NegativeFilter

public class BlurFilter extends Filter ParameterizedFilter PointFilter BlurFilter MultiFilter IntParameterizedFilter StringParameterizedFilter NegativeFilter AverageFilter public class BlurFilter extends Filter implements ParameterizedFilter { private int param; public void setParameter(int val) { param = val; } public int getParameter() { return param; } public String getPrompt() { return “Enter the blurring factor: ”; } ... } Option 3: Interface public interface ParameterizedFilter { public void setParameter(int val); public int getParameter(); public String getPrompt(); }

PS5 Designs [Throughout the Day] 1. Blanton, James Kalish, Michael 2. Borja, Joseph Oh, Uyn Noh, Brian 3. Brown, Jeremy Hearn, Charles 4. Chen, Jiamin Sparkman, Elisabeth Sun, Yixin 5. Dewey-Vogt, Michael Lopez, Erik 6. Dilorenzo, Jonathan Featherston, Joseph 7. Dollhopf, Niklaus Marion, John 8. Herder, Samuel Wallace, Alexander