31
Introduction

Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

Introduction

Page 2: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

2 COMPSCI 107 - Computer Science Fundamentals

Page 3: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

3 COMPSCI 107 - Computer Science Fundamentals

Page 4: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

4 COMPSCI 107 - Computer Science Fundamentals

Page 5: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

ACM Special Interest Group in Computer Science Education

5 COMPSCI 107 - Computer Science Fundamentals

Page 6: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

6 COMPSCI 107 - Computer Science Fundamentals

Page 7: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

An efficient way to teach – not an effective way to learn Research on learning: Actively doing something is effective Learning from peers is effective Critically evaluating your own performance is essential

8 COMPSCI 107 - Computer Science Fundamentals

Page 8: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

What is effective? Actively doing something (bring laptop to class if possible) Critically evaluating yourselves Learning from peers

9 COMPSCI 107 - Computer Science Fundamentals

Page 9: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

Laboratories every week (starting week 2) ……… 25% Exercises during labs Exercises after labs(homework)

Mid-semester Test …………………………………………… 15% 1st May 205, in class, during normal lecture time

Final Exam ……………………………………………………….. 60% Date to be announced

10 COMPSCI 107 - Computer Science Fundamentals

Page 10: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

Computer feedback Errors, testing, debugging

Automated marking CodeRunner – automated testing

Laboratory feedback Demonstrators Group code review

11 COMPSCI 107 - Computer Science Fundamentals

Page 11: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

Lectures Overheads and recordings

Forum Question and answers – peers, tutors and lecturers

Textbook Problem Solving with Algorithms and Data Structures Online, free, open source

Additional resources Python.org PythonTutor.com

12 COMPSCI 107 - Computer Science Fundamentals

Page 12: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

Making informed choices about programming Building mental models of data storage and control flow Understanding the trade-offs

Focus on ways of storing and manipulating data Different ways of structuring data storage Efficiency Searching Sorting

Some new programming ideas Recursion Exceptions

13 COMPSCI 107 - Computer Science Fundamentals

Page 13: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

Programs consist of one or more instructions Instructions are executed in a sequence

14 COMPSCI 107 - Computer Science Fundamentals

Page 14: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

A simple storage box name of the box is the identifier stores only one thing at a time

Information in a variable has a type boolean, integer, float, string you can perform different operations on different types of data

Values are stored in variables using an assignment statement

15 COMPSCI 107 - Computer Science Fundamentals

25

age

name = "Andrew" age = 25

Page 15: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

Conditional statements Change the flow of control Conditions must evaluate to true or false (boolean) Execute additional statements if condition is true

Used to make decisions

16 COMPSCI 107 - Computer Science Fundamentals

discount = 0.0 age = int(input("Enter your age: ")) if age >= 65: discount = 0.10 print("You get a discount of {:.0%}".format(discount)) price = 35 * (1.0 - discount) print("Your tickets cost: ${:.2f}".format(price))

Page 16: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

Loops Change the flow of control Execute a set of statements multiple times Branch when the condition is false

Similar to a conditional but repeats the statements Python hides some of the details

17 COMPSCI 107 - Computer Science Fundamentals

tables = int(input("Enter the times tables: ")) print("===============") for i in range(1, 11): print("{} x {} = {}".format(i, tables, i * tables)) print("===============")

Page 17: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

Functions (procedures, methods, subroutines) are a way to group statements together as a unit An identifier is used to label the function (function name) Parameters make the code more general Code can return a value

18 COMPSCI 107 - Computer Science Fundamentals

def rectangle_area(width, height): area = width * height return area

function name function parameters

return value

Page 18: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

Arrays Python hides these, but they are fundamentally important Single variable name refers to a sequence of variables Integer values used as an "index" to specify which variable in the sequence is required Position of the information in memory can be calculated using formula:

19 COMPSCI 107 - Computer Science Fundamentals

location = location_of_position_0 + index * memory_size_of_each_element

my_list = ["w", "p", "c", "g", "x", "a"] print(my_list[0]) print(my_list[3])

Page 19: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

Object oriented programming Defining a class (type) Group data and code operating on that data

Modular, reusable Separate interface from implementation

20 COMPSCI 107 - Computer Science Fundamentals

class coordinates: #Note, coordinates are (x, y) integer values on cartesian plane def __init__(self, x, y): self.x = x self.y = y def __repr__(self): return "({}, {})".format(self.x, self.y)

Page 20: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

Testing code Use unit tests Check output of functions with a variety of input values Automate the testing process as much as possible

Defensive programming Anticipate incorrect data and handle the problem without causing runtime errors

Runtime errors Exception handling system

21 COMPSCI 107 - Computer Science Fundamentals

Page 21: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

Used to compare different ways of working with data Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute a program in terms of

the number of data elements

22 COMPSCI 107 - Computer Science Fundamentals

Page 22: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

List with constrained access to data Stack adds and removes from the same end of the list Queue adds to one end and removes from the other end

Stack Last In, First Out

Queue First in, First out

23 COMPSCI 107 - Computer Science Fundamentals

Page 23: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

Array-based lists

Singly linked lists Doubly linked lists

24 COMPSCI 107 - Computer Science Fundamentals

Page 24: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

Programming technique allowing problem solving

25 COMPSCI 107 - Computer Science Fundamentals

def fib(n): if n == 0 or n == 1: return n if n >= 2: return fib(n - 1) + fib(n - 2)

Page 25: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

Storing (key, value) pairs efficiently Take any key and convert into a number between 0 and N - 1 Use an array of size N to store the value Deal with conflicts in a consistent way Very fast storage and access BUT – not appropriate for ordered data

26 COMPSCI 107 - Computer Science Fundamentals

Each key converted into an index value

Page 26: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

Linear search Look at each element Works with any kind of data

Binary search Halve the search space each time Works with ordered data

27 COMPSCI 107 - Computer Science Fundamentals

Page 27: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

Different sorting algorithms have different trade-offs Overall efficiency Number of comparisons Number of swaps Nature of the data (sorted, unsorted) Stability

28 COMPSCI 107 - Computer Science Fundamentals

http://www.sorting-algorithms.com/

Page 28: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

Recursive data storage Each node has links to other nodes

29 COMPSCI 107 - Computer Science Fundamentals

Page 29: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

Storing ordered data

30 COMPSCI 107 - Computer Science Fundamentals

Heap

Binary Search Tree

Page 30: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

Pattern matching text data

31 COMPSCI 107 - Computer Science Fundamentals

Page 31: Software Engineering 250 · 2015. 3. 1. · Interested in scalability – how does time increase with data increase? Write a formula that describes how much time it takes to execute

Introduction to structured programming using Python Focus on ways of storing and manipulating data data structures algorithms

Understanding tradeoffs

32 COMPSCI 107 - Computer Science Fundamentals