CS 351: Design of Large Programs.

Similar documents
CS 105 Introduction to Computer Programming in JavaScript Midterm Exam Review

CSCE 210/2201 Data Structures and Algorithms. Prof. Amr Goneid

CSCE 210/2201 Data Structures and Algorithms. Prof. Amr Goneid. Fall 2018

McGill University School of Computer Science COMP-202A Introduction to Computing 1

CS 241 Data Organization. August 21, 2018

CS302 Data Structures using C++

Announcements. 1. Forms to return today after class:

Computer Science II Data Structures

Intro. Scheme Basics. scm> 5 5. scm>

San José State University Department of Computer Science CS-144, Advanced C++ Programming, Section 1, Spring 2018

Welcome to... CS113: Introduction to C

Getting Started in Your Blackboard 5 Course

Midterm Exam #2 Review. CS 2308 :: Spring 2016 Molly O'Neil

CSCI 136 Data Structures & Advanced Programming. Fall 2018 Instructors Bill Lenhart & Bill Jannen

CMPE/SE 135 Object-Oriented Analysis and Design

CS2013 Course Syllabus Spring 2017 Lecture: Friday 8:00 A.M. 9:40 A.M. Lab: Friday 9:40 A.M. 12:00 Noon

Course: Honors AP Computer Science Instructor: Mr. Jason A. Townsend

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

You must pass the final exam to pass the course.

Adam Blank Lecture 2 Winter 2019 CS 2. Introduction to Programming Methods

CS 241 Data Organization using C

l Determine if a number is odd or even l Determine if a number/character is in a range - 1 to 10 (inclusive) - between a and z (inclusive)

University of Waterloo Department of Electrical and Computer Engineering ECE 250 Algorithms and Data Structures

CS 211 Programming Practicum Spring 2017

Lab 4: Imperative & Debugging 12:00 PM, Feb 14, 2018

CS2013 Course Syllabus Spring 2018 Lecture: Mon/Wed 2:00 P.M. 2:50 P.M. SH C259 Lab: Mon/Wed 2:50 P.M. 4:00 P.M. SH C259

CSE wi: Practice Midterm

Final Exam CS 251, Intermediate Programming December 10, 2014

BCIS 3630 Dr. GUYNES SPRING 2018 TUESDAY SECTION [JAN version] GRADER COURSE WEBSITE

MPATE-GE 2618: C Programming for Music Technology. Syllabus

Lecture 1: Overview & Intro to Java

KOMAR UNIVERSITY OF SCIENCE AND TECHNOLOGY (KUST)

Lecture 6. COMP1006/1406 (the OOP course) Summer M. Jason Hinek Carleton University

CSE373 Fall 2013, Midterm Examination October 18, 2013

MIDTERM EXAMINATION Douglas Wilhelm Harder EIT 4018 x T09:30:00P1H20M Rooms: RCH-103 and RCH-302

! Mon, May 5, 2:00PM to 4:30PM. ! Closed book, closed notes, clean desk. ! Comprehensive (covers entire course) ! 30% of your final grade

! Determine if a number is odd or even. ! Determine if a number/character is in a range. - 1 to 10 (inclusive) - between a and z (inclusive)

Introduction to Programming System Design CSCI 455x (4 Units)

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 9: OCT. 4TH INSTRUCTOR: JIAYIN WANG

CS 4349 Lecture October 18th, 2017

CS 177 Week 15 Recitation Slides. Review

CS61BL: Data Structures & Programming Methodology Summer 2014

Programming with Arrays Intro to Pointers CS 16: Solving Problems with Computers I Lecture #11

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

LinkedList Implementation Mini-project intro

Welcome to CSSE 220. We are excited that you are here:

COMP Data Structures

! Determine if a number is odd or even. ! Determine if a number/character is in a range. - 1 to 10 (inclusive) - between a and z (inclusive)

Welcome to Blackboard

CS503 Advanced Programming I CS305 Computer Algorithms I

Remaining Enhanced Labs

CS 220: Introduction to Parallel Computing. Arrays. Lecture 4

PIC 10A. Review for Midterm I

COMP Data Structures

University of Illinois at Urbana-Champaign Department of Computer Science. Final Examination

CS 0449 Intro to Systems Software Fall Term: 2181

Introduction to C. CS 2060 Week 1. Prof. Jonathan Ventura. Outline Introduction Introduction to C Homework 1 C Coding Style Wrap-up

CSE030 Fall 2012 Final Exam Friday, December 14, PM

Outline. CIS 110: Introduction to Computer Programming. What is Computer Science? What is computer programming? What is computer science?

CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims. Lecture 25: Review and Open Problems

CSE 142 Su01 Final Exam Sample Solution page 1 of 7

Object-Oriented Programming for Managers

BOSTON UNIVERSITY Metropolitan College MET CS342 Data Structures with Java Dr. V.Shtern (Fall 2011) Course Syllabus

COURSE OF STUDY UNIT PLANNING GUIDE COMPUTER SCIENCE 1 FOR: 5 CREDITS GRADE LEVEL: 9-12 FULL-YEAR COURSE PREPARED BY: SUSIE EISEN

Curriculum Map Grade(s): Subject: AP Computer Science

Introduction to Computation and Problem Solving

BLACKBOARD CE6 Guide. Workshop Handout

Announcements. Course syllabus Tutorial/lab signup form (due 4pm today) Lecture 1 notes Homework 1 Initial assessment

LIS 2680: Database Design and Applications

Revising CS-M41. Oliver Kullmann Computer Science Department Swansea University. Linux Lab Swansea, December 13, 2011.

CSC 111 Introduction to Computer Science (Section C)

Updated: 2/14/2017 Page 1 of 6

College Board. AP CS A Labs Magpie, Elevens, and Picture Lab. New York: College Entrance Examination Board, 2013.

CSE 332 Spring 2013: Midterm Exam (closed book, closed notes, no calculators)

Introduction to Data Structures

CS 211 Programming Practicum Fall 2018

Largest Online Community of VU Students

CS162 Week 1. Kyle Dewey. Friday, January 10, 14

Inf1-OP. Inf1-OP Exam Review. Timothy Hospedales, adapting earlier version by Perdita Stevens and Ewan Klein. March 20, School of Informatics

More on Arrays CS 16: Solving Problems with Computers I Lecture #13

Practice Final Examination #2

CMSC132, Practice Questions

Lecture 10. Graphs Vertices, edges, paths, cycles Sparse and dense graphs Representations: adjacency matrices and adjacency lists Implementation notes

CS 211 Programming Practicum Spring 2018

CS 206 Introduction to Computer Science II

An Introduction to Blackboard

I. True/False: (2 points each)

Revising CS-M41. Oliver Kullmann Computer Science Department Swansea University. Robert Recorde room Swansea, December 13, 2013.

Java for Non Majors. Final Study Guide. April 26, You will have an opportunity to earn 20 extra credit points.

COMP 261 ALGORITHMS and DATA STRUCTURES

Midterm Exam CS 251, Intermediate Programming March 12, 2014

CIS 101 Orientation Document Fall 2017

Spring 2003 Instructor: Dr. Shahadat Hossain. Administrative Matters Course Information Introduction to Programming Techniques

Inf1-OOP. OOP Exam Review. Perdita Stevens, adapting earlier version by Ewan Klein. March 16, School of Informatics

Java Programming. Computer Science 112

(Refer Slide Time: 00:18)

CMPE 152 Compiler Design

CISC-235* Test #3 March 19, 2018

CS314: FORMAL LANGUAGES AND AUTOMATA THEORY L. NADA ALZABEN. Lecture 1: Introduction

This page intentionally left blank

Transcription:

Welcome to CS 351 Design of Large Programs Instructor: Joel Castellanos e-mail: joel@unm.edu Web: http://cs.unm.edu/~joel/ Office: Electrical and Computer Engineering building (ECE). Room 233 1/18/2017 Computer Science Course Sequence CS 105: Intro programming JavaScript and HTML5, currently optional. CS 152: Intro programming Java. More rigorous than 105. CS 251: Intermediate programming Java. CS 261: Mathematical Foundations of Computer Science. CS 241: Data Organization using C. CS 357: Declarative Programming. CS 351: Design of Large Programs. 2 CS 361: Algorithms I. 1

Who Should Be Here? Before attempting CS 351, you need to already know how to program. For example, you should already be able to use Java to create a Graphical User Interface with working buttons, and sliders. You should be able to draw figures on a JPanel. If you have not had CS 152, CS 251, CS 241 AND CS 261, then you should take those first. If you do not know how to program, start with CS 152. If you know basic programming, but not OOP and have not created GUIs in Java, C++ or some other language, then take CS 251. 3 Course Description 4 CS 351 is about designing big software, where big refers to projects with a scope too large to be handled by: Any one person (communication with collaborators) At any one time (communication with "ghosts" of past and "apparitions" of future). Any semester long project is "small" by industry standards but I will do my best to push you to your limits of complexity. CS 351 primarily deals with software design, time management, and strategies for completing complex coding. Java 1.8. IntelliJ (IDE). GitHub version control software and repo. 2

Quiz: Write a method in Java or C++ that... 1) Takes no arguments. 2) Does not return a value. 3) Uses a nested loop to display to the console a 15 x 15 multiplication table. 4) The multiples of 1 (1 through 15) must print on the first line with at least one space between each number. 5) The multiples of 2 (2, 4, 6,... 30) must print on the second line with at least one space between each number. 6) The same must be true for each of the other multiples. 5 Global Game Jam UNM hosting NM site for Global Game Jam Day 1 FRIDAY (1/20): 6:00 PM Theme reveal Day 3 SUNDAY (1/22): 5:00 PM Game Jam Ends Global Game Jam a 48 hour game development event. Whether you're a game developer, coder, artist, musician, or have really good ideas, you can be part of this cool event. REGISTRATION http://globalgamejam.org/2017/jam sites/unm mesa del sol More information: http://globalgamejam.org/faq 6 3

Course Resources Blackboard Learn: https://learn.unm.edu/ Assignement Drop box Assignement Discussions (blogs) Grades 7 Class website: http://cs.unm.edu/~joel/cs351/ Syllabus Projects Lecture Notes Readings Assignments Source Code Grading 60%: Individual and Group Programming Projects. 20%: Class Participation (quizzes, code reviews, and discussions). 10%: Midterm exam (take home, short essay). 10%: Final exam (take home, short essay). 8 4

Class Discussion of Reading Be prepared to discuss: What major points were made and/or methods used? What was well explained and/or particularly interesting? What was confusing and/or uninteresting? Did the authors make any unstated assumptions? If so, what are they, what are some reasons they might be false, how likely are those reasons and how would that effect the results? Was the writing good? How could it be improved? 9 Grading Discussion of Reading I will pick random students from the roster and call on you to answer. Then, I will open each question to general discussion. If you did not have a good answer to a question you are asked, than MAKE SURE you do have something intelligent to say in one of the general discussion on that same day. In general, there are not specific answers I expect you to have. What I do expect, is for you to make it clear to me that you have read the article and have thought intelligently about it. If English is not your first language, or for some other reason, you feel worried about expressing yourself orally, then speak with me after class today. 10 5

Quiz (do on paper, PRINT your name) In Java, what is a static initializer and what would be a good reason for using one? In Java, what is an instance field initializer? How is an instance field initializer different from a static initializer? Why would it be better to use an instance field initializer rather than placing the code inside the object constructor? 11 What is a Large Program? This course is the Design of Large Programs. What does that mean? 12 6

Quiz: A* Given the map below that allows 4 directions of movement with coast of either 1 (empty) or infinity (wall). Show the contents of A*'s priority queue after 10 elements have been added. Each element of the queue contains three values: x, y and weight. At step 0, the queue contains (0, 3, 8). 13 0 1 2 3 4 5 0 F 1 2 3 S Graph (Abstract Data Type) In computer science, a graph is an abstract data type that is meant to implement the undirected graph and directed graph concepts from mathematics. A graph data structure consists of a finite (and possibly mutable) set of vertices (nodes), connected by a set of edges (arcs) for an undirected graph or directed edges (arrows or directed arcs) for a directed graph. 14 7

Adjacency Matrix for 5 word Dictionary green greed reed red bed green 0 1 0 0 0 greed 1 0 1 0 0 reed 0 1 0 1 0 red 0 0 1 0 1 bed 0 0 0 1 0 15 Suggestions in Building the Graph (1 of 4) Create a Node class: String name, An array of 3 ArrayList<Node> edgelist: one with pointers to all single change words that are one letter shorter than this word, one for those of the same length and one for those one letter longer. Later, after you have build the graph and are ready to start finding the shortest path, you can add fields for visited, costsofar, and whatever else you might need. 16 8

Suggestions in Building the Graph (2 of 4) 17 Create your own dictionary with only 25 or 30 words having 3, 4 and 5 letters. This will allow you to print out your entire graph structure and check it by hand for correctness. For example, if your dictionary is: bed, greed, green, red, and reed. Then your graph could be printed as: bed: red red: bed, reed reed: red, greed greed: reed, green green: greed This printing order of both nodes and their edges is a natural outcome of the input dictionary being in alphabetical order and keeping words of a length in separate array lists. Suggestions in Building the Graph (3 of 4) 1) Build the graph one word at a time as you read the dictionary. 2) A simple and good structure to hold the word nodes is an array of ArrayLists: one ArrayList for all words of each length found in the dictionary. As a word is read, append it to the appropriate ArrayList and it never needs to move! 3) Just before you add the new node to its ArrayList, walk linearly through each word in the three ArrayLists for words of length 1 of the new word. If the examined word is one change from the new word, then 1) add the new word to that found word's edge list and add the found word to the new word's edge list. After reading the last word, the graph is done! 18 9

Suggestions in Building the Graph (4 of 4) The structure outlined on the last slide is simple and efficient: When finding a path, from word1 to word2, you need to find word1 in the graph: Jump to the ArrayList for words of the length of word1. By construction, the words in each ArrayList will be in alphabetical order so do a simple and quick binary search. 19 Hamming Distance The Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. It measures the minimum number of substitutions required to change one string into the other. "karolin" "kathrin" "karolin" "kerstin" Hamming distance = 3 Hamming distance = 3 20 10

Levenshtein Distance The Levenshtein distance is a string metric for measuring the difference between two sequences. Informally, the Levenshtein distance between two words is the minimum number of singlecharacter edits (i.e. insertions, deletions or substitutions) required to change one word into the other. 21 Upper and lower bounds: It is always at least the difference of the sizes of the two strings. It is at most the length of the longer string. It is zero if and only if the strings are equal. If the strings are the same size, the Hamming distance is an upper bound on the Levenshtein distance. The Levenshtein distance between two strings is no greater than the sum of their Levenshtein distances from a third string. Levenshtein Distance Hamming Distance An example where the Levenshtein distance between two strings of the same length is strictly less than the Hamming distance: "flaw" and "lawn". Here the Levenshtein distance equals 2 (delete "f" from the front; insert "n" at the end). The Hamming distance is 4. 22 11

Efficient Check: is A one delete from B A b u m f u z z l e B b u m f z z l e 23 Avoid creating temporary storage (such as breaking each word into every possible substring). Avoid comparing a pair of letters more than once. Use.charAt(int idx) on the existing String. Let offset be the current shift in index from B to A. Initialize: offset=0. If, a difference is found and offset=0, then offset=1. If, a difference is found and offset=1, then break. Quiz 1) In Java, what are generics? 2) In Java, when are static initializers called? 24 12

Project Structure (within.jar) Your basic project structure should always be: projectroot/readme.txt projectroot/src for source code in correct package structure. projectroot/toplevelpackage with.class files in correct package structure. projectroot/data for data files and resources. projectroot/doc for JavaDoc. Do not use the package com.company Do not use deep and/or mostly empty packages. 25 This code compiles and runs correctly. How can it be improved? for (int i=0; i<getclient().getuser().size(); i++) { card = new PolicyCard(getClient().getUser().get(i), getclient().getuser().getregion()); 26 } if (card.votesrequired()==0) { novotes.add(getclient().getuser().get(i)); } else { votes.add(getclient().getuser().get(i)); } 13

Why is this stupid? 27 private void initializeproductlist() { //Add each enum in EnumFood to productlist. productlist = new ArrayList<>(); productlist.add(enumfood.tropical_fruit); productlist.add(enumfood.temperate_fruit); productlist.add(enumfood.nut); productlist.add(enumfood.grain); productlist.add(enumfood.oil); productlist.add(enumfood.veggies); productlist.add(enumfood.spice); productlist.add(enumfood.fish); productlist.add(enumfood.meat); productlist.add(enumfood.poultry); productlist.add(enumfood.dairy); } 14