Program Design Invasion Percolation: Aliasing

Slides:



Advertisements
Similar presentations
Input and Output Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Advertisements

Introduction Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Introduction Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Introduction Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Interfaces Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Slicing Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Tuples Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Floating Point Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Control Flow Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Copyright © 2014 Dr. James D. Palmer; This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
Unit Testing Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
(a) (b) (c) (d). What is (1,2,3)  (3,4,2)? (a) (1, 2, 3, 4) (b) (1,2)  (3,4) (c) (1,3,4,2) (d) (3,1)  (4,2)
Introduction Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
BEGINNER EV3 PROGRAMMING LESSON By: Droids Robotics Topics Covered: Display Block.
Mechanics Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
1 Debugging and Testing Overview Defensive Programming The goal is to prevent failures Debugging The goal is to find cause of failures and fix it Testing.
Functions Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Fixtures Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Copyright © Software Carpentry 2012 This work is licensed under the Creative Commons Attribution License See
Nanotech Example Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Linked Structures See Section 3.2 of the text.. First, notice that Java allows classes to be recursive, in the sense that a class can have an element.
Invasion Percolation: Assembly Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Browsing Directories Copyright © Software Carpentry and The University of Edinburgh This work is licensed under the Creative Commons Attribution.
Pipes and Filters Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Macros Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Interface and Implementation Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Storage Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Introduction Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Inheritance Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Introduction Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Introduction Copyright © Software Carpentry This work is licensed under the Creative Commons Attribution License See
Basics Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
More Patterns Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Lists Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Rollback Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Copyright © 2012 The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Chapter 13: Systems Analysis and Design Steps in programming.
Invasion Percolation: Randomness Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Exceptions Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Patterns Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See
Multiplication Timed Tests.
Copyright Issues Miss Taylor 6A - Term 2 What is Copyright?  In simple terms – a bunch of rights relating to creative work  Music  Photos  Writing.
Python Aliasing Copyright © Software Carpentry 2010
Program Design Invasion Percolation: Testing
Sets and Dictionaries Examples Copyright © Software Carpentry 2010
Program Design Invasion Percolation: Resolving Ties
Programming Abstractions
Program Design Invasion Percolation: Neighbors
By Sanjay and Arvind Seshan
Copyright and Creative Commons
BROADCAST LAW COPYRIGHT TERMS.
BEGINNER EV3 PROGRAMMING Lesson
Software Quality Assurance
Welcome back to Software Development!
Microscope Questions Now that you have EXPLORED the different types of microscopes, it is now time for the opportunity to demonstrate and explain what.
Programming Abstractions
First we need to draw a place table grid. Then write our number in it
BROADCAST LAW COPYRIGHT TERMS.
Version Control Basic Operation Copyright © Software Carpentry 2010
BEGINNER PROGRAMMING LESSON
Positive/Negative Space
Copyright and Creative Commons
Version Control Introduction Copyright © Software Carpentry 2010
Nate Brunelle Today: Lists
Program Design Invasion Percolation: Bugs
Geometry.
Version Control Conflict Copyright © Software Carpentry 2010
Program Design Invasion Percolation: The Grid
Browsing Directories Using walk
BEGINNER EV3 PROGRAMMING Lesson
Positive/Negative Space
Presentation transcript:

Program Design Invasion Percolation: Aliasing Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See http://software-carpentry.org/license.html for more information.

Use lists of lists to implement a 2D grid 3 5 7 7 5 8 6 3 2 4 2 6 5 4

Use lists of lists to implement a 2D grid 3 5 7 7 5 8 6 3 2 4 2 6 5 4

Use lists of lists to implement a 2D grid 3 5 7 7 5 8 6 3 2 4 2 6 5 4

assert N > 0, "Grid size must be positive" # Correct code assert N > 0, "Grid size must be positive" assert N%2 == 1, "Grid size must be odd" grid = [] for x in range(N): grid.append([]) for y in range(N): grid[-1].append(1) 5

assert N > 0, "Grid size must be positive" # Incorrect code assert N > 0, "Grid size must be positive" assert N%2 == 1, "Grid size must be odd" grid = [] EMPTY = [] for x in range(N): grid.append(EMPTY) for y in range(N): grid[-1].append(1) 6

assert N > 0, "Grid size must be positive" # Incorrect code assert N > 0, "Grid size must be positive" assert N%2 == 1, "Grid size must be odd" grid = [] EMPTY = [] for x in range(N): grid.append(EMPTY) for y in range(N): grid[-1].append(1) 7

"Aren't meaningful variable names supposed to be a good thing?" # Incorrect code assert N > 0, "Grid size must be positive" assert N%2 == 1, "Grid size must be odd" grid = [] EMPTY = [] for x in range(N): grid.append(EMPTY) for y in range(N): grid[-1].append(1) "Aren't meaningful variable names supposed to be a good thing?" 8

grid = [] grid 9

grid = [] EMPTY = [] grid EMPTY 10

grid = [] EMPTY = [] for x in range(N): # x == 0 grid.append(EMPTY) 11

grid = [] EMPTY = [] for x in range(N): # x == 0 grid.append(EMPTY) for y in range(N): # y == 0 grid[-1].append(1) grid EMPTY 1 12

grid = [] EMPTY = [] for x in range(N): # x == 0 grid.append(EMPTY) for y in range(N): # y == 1 grid[-1].append(1) grid EMPTY 1 1 13

grid = [] EMPTY = [] for x in range(N): # x == 0 grid.append(EMPTY) for y in range(N): # y == 2 grid[-1].append(1) grid EMPTY 1 1 1 14

grid = [] EMPTY = [] for x in range(N): # x == 1 grid.append(EMPTY) 15

grid = [] EMPTY = [] for x in range(N): # x == 1 grid.append(EMPTY) for y in range(N): # y == 0 grid[-1].append(1) grid EMPTY 1 1 1 1 16

You see the problem... grid = [] EMPTY = [] for x in range(N): # x == 1 grid.append(EMPTY) for y in range(N): # y == 0 grid[-1].append(1) grid EMPTY 1 1 1 1 You see the problem... 17

Indirection allows aliasing

Indirection allows aliasing Aliasing can be useful

Indirection allows aliasing Aliasing can be useful (In fact, sometimes it's indispensible)

Indirection allows aliasing Aliasing can be useful (In fact, sometimes it's indispensible) But it's also a rich source of bugs

Indirection allows aliasing Aliasing can be useful (In fact, sometimes it's indispensible) But it's also a rich source of bugs When in doubt, draw a picture!

Indirection allows aliasing Aliasing can be useful (In fact, sometimes it's indispensible) But it's also a rich source of bugs When in doubt, draw a picture! Tools that do this automatically exist...

Indirection allows aliasing Aliasing can be useful (In fact, sometimes it's indispensible) But it's also a rich source of bugs When in doubt, draw a picture! Tools that do this automatically exist... ...but none has really taken off (yet)

Greg Wilson created by May 2010 Copyright © Software Carpentry 2010 This work is licensed under the Creative Commons Attribution License See http://software-carpentry.org/license.html for more information.