1 / 11

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

loring
Télécharger la présentation

Class 16: Concurrency Rules

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. cs2220: Engineering Software Class 16:Concurrency Rules Fall 2010 UVa David Evans Picture by Jonathan Dilorenzo

  2. 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

  3. 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 BinaryTreegetChild (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?

  4. 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 BinaryTreegetChild (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!

  5. 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 BinaryTreegetChild (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?

  6. 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 BinaryTreegetChild (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;

  7. 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

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

  9. Filter Option 1: Filter subtype ParameterizedFilter MultiFilter PointFilter BlurFilter ParameterizedBlurFilter AverageFilter NegativeFilter Filter ParameterizedFilter Option 2: public intgetParameter(); public abstract booleanhasParameter(); MultiFilter PointFilter BlurFilter AverageFilter NegativeFilter

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

  11. 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

More Related