SECTION 2: Loop Reasoning & HW3 Setup

Similar documents
SECTION 2: Loop Reasoning & HW3 Setup

SECTION 2: HW3 Setup.

Section 2: Developer tools and you. Alex Mariakakis (staff-wide)

SECTION 1: CODE REASONING + VERSION CONTROL + ECLIPSE

SECTION 1: CODE REASONING + VERSION CONTROL

SECTION 1: CODE REASONING + VERSION CONTROL

hw6, BFS, debugging CSE 331 Section 5 10/25/12 Slides by Kellen Donohue

CSE 331 Software Design & Implementation

Warmup. A programmer s wife tells him, Would you mind going to the store and picking up a loaf of bread? Also, if they have eggs, get a dozen.

CSE 332: Data Structures and Parallelism Winter 2019 Setting Up Your CSE 332 Environment


SECTION 2: CODE REASONING + PROGRAMMING TOOLS. slides borrowed and adapted from Alex Mariakis and CSE 390a

Revision Control. How can 4. Slides #4 CMPT 276 Dr. B. Fraser. Local Topology Simplified. Git Basics. Revision Control:

CSE 390 Lecture 9. Version control and Subversion (svn)

What is version control? (discuss) Who has used version control? Favorite VCS? Uses of version control (read)

CSE 391 Lecture 9. Version control with Git

Module Road Map. 7. Version Control with Subversion Introduction Terminology

CPSC 491. Lecture 19 & 20: Source Code Version Control. VCS = Version Control Software SCM = Source Code Management

The Old World. Have you ever had to collaborate on a project by

Revision control. INF5750/ Lecture 2 (Part I)

Version Control. Second level Third level Fourth level Fifth level. - Software Development Project. January 11, 2017

Software Development I

TDDC88 Lab 4 Software Configuration Management

Using GitHub to Share with SparkFun a

Git AN INTRODUCTION. Introduction to Git as a version control system: concepts, main features and practical aspects.

Object Oriented Programming. Week 1 Part 2 Git and egit

Git Setup Help using GitKraken (CSE 154)

Git AN INTRODUCTION. Introduction to Git as a version control system: concepts, main features and practical aspects.

git commit --amend git rebase <base> git reflog git checkout -b Create and check out a new branch named <branch>. Drop the -b

Version Control Systems

Version Control System GIT

Tutorial 2 GitHub Tutorial

Handout 4: Version Control Reference

Version Control. Second level Third level Fourth level Fifth level. - Software Development Project. January 17, 2018

Windows. Everywhere else

b. Developing multiple versions of a software project in parallel

Debugging in Small Basic is the process of analysing a program to detect and fix errors or improve functionality in some way.

WORKING IN TEAMS WITH CASECOMPLETE AND THE CASECOMPLETE PROJECT SHARING ADDIN. Contents

Version Control Systems (Part 1)

Version Control System - Git. zswu

Lab 01 How to Survive & Introduction to Git. Web Programming DataLab, CS, NTHU

Intro to Github. Jessica Young

Storing and Managing Code with CVS

Today s presentation. Git gdb Project 1

WORKING IN TEAMS WITH CASECOMPLETE AND SUBVERSION. Contents

Version Control with Git ME 461 Fall 2018

The NetBeans IDE is a big file --- a minimum of around 30 MB. After you have downloaded the file, simply execute the file to install the software.

Using Git to Manage Source RTL

Submitting your Work using GIT

CSC 2700: Scientific Computing

Liquibase Version Control For Your Schema. Nathan Voxland April 3,

A quick (and maybe practical) guide to Git and version control. By Jay Johnson

2/9/2013 LAB OUTLINE INTRODUCTION TO VCS WHY VERSION CONTROL SYSTEM(VCS)? II SENG 371 SOFTWARE EVOLUTION VERSION CONTROL SYSTEMS

Introduction to Computation and Problem Solving

Git, the magical version control

USING DRUPAL. Hampshire College Website Editors Guide

USER GUIDE MADCAP LINGO Source Control: Git

Software Tools Subversion

Agenda. - Final Project Info. - All things Git. - Make sure to come to lab for Python next week

CSE 374 Programming Concepts & Tools. Hal Perkins Winter 2012 Lecture 16 Version control and svn

Code::Blocks Student Manual

A Tutorial for ECE 175

Lab 08. Command Line and Git

Version control CSE 403

Lab Exercise Test First using JUnit

Technology Background Development environment, Skeleton and Libraries

Technology Background Development environment, Skeleton and Libraries

Lab Exercise 1 Using EGit and JUnit

USER GUIDE. MADCAP FLARE 2017 r3. Source Control: Git

How to version control like a pro: a roadmap to your reproducible & collaborative research

Under the Debug menu, there are two menu items for executing your code: the Start (F5) option and the

Web API Lab. The next two deliverables you shall write yourself.

CESSDA Expert Seminar 13 & 14 September 2016 Prague, Czech Republic

HOW TO USE CODE::BLOCKS IDE FOR COMPUTER PROGRAMMING LABORATORY SESSIONS

Lesson 9 Transcript: Backup and Recovery

Branches in Subversion, Debugging, scmbug

Distributed Version Control

COSC345 Software Engineering. Version Control

GDB Tutorial. A Walkthrough with Examples. CMSC Spring Last modified March 22, GDB Tutorial

1. Which of these Git client commands creates a copy of the repository and a working directory in the client s workspace. (Choose one.

How to set up SQL Source Control The short guide for evaluators

Using git to download and update BOUT++

CVS. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 21

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG

SmartCVS Tutorial. Starting the putty Client and Setting Your CVS Password

Code::Blocks Student Manual

FEEG Applied Programming 3 - Version Control and Git II

Introduction to IntelliJ

Introduction to Git and GitHub for Writers Workbook February 23, 2019 Peter Gruenbaum

Version Control. CSC207 Fall 2014

Common Git Commands. Git Crash Course. Teon Banek April 7, Teon Banek (TakeLab) Common Git Commands TakeLab 1 / 18

CS108, Stanford Handout #37. Source Control CVS

A L A TEX-oriented intro to Git


What is git? Distributed Version Control System (VCS); Created by Linus Torvalds, to help with Linux development;

Git version control with Eclipse (EGit) Tutorial

A Brief Introduction to Git. Sylverie Herbert (based on slides by Hautahi Kingi)

1.00 Lecture 2. What s an IDE?

Git. all meaningful operations can be expressed in terms of the rebase command. -Linus Torvalds, 2015

Chapter 3. Revision Control

Transcription:

SECTION 2: Loop Reasoning & HW3 Setup cse331-staff@cs.washington.edu slides borrowed and adapted from CSE 331 Winter 2018, CSE 391, and many more

Review: Reasoning about loops What is a loop invariant? An assertion that always holds at the top of a loop Why do we need invariants? Most code is not straight line Most programs aren t guaranteed to terminate Therefore: We need invariants to prove the correctness of most programs we can encounter Additionally, invariants help us write correct programs!

Loop Invariants & Hoare Triples We can write a Hoare Triple involving a loop {P} while(b) S {Q} The three key ingredients for a valid loop Hoare triple are: The Invariant holds initially (precondition implies invariant) P => I Loop body must re-establish the invariant (Inv holds each time we execute) {I B} S {I} Upon exiting the loop (test is false), the invariant must establish post-condition {I!B} => Q

Loop Invariants ct. We want a goldilocks invariant not too strong false and cannot be proven not too weak cannot satisfy our postcondition No sure-fire way to find a loop invariant Bad: Coding first and defining the invariant later Good: think of invariant --> code the body --> code the loop condition --> code the initialization The common types of problems involving loop invariants include: Given the code, fill in the assertions / invariant Given a proof, find the error(s) in it if it is incorrect Given the invariant, fill in the code

VERSION CONTROL

WHAT IS VERSION CONTROL? Also known as source control/revision control System for tracking changes to code Software for developing software Essential for managing projects See a history of changes Revert back to an older version Merge changes from multiple sources We ll be talking about git/gitlab, but there are alternatives Subversion, Mercurial, CVS Email, Dropbox, USB sticks (don t even think of doing this)

VERSION CONTROL ORGANIZATION A repository stores the master copy of the project Someone creates the repo for a new project Then nobody touches this copy directly Lives on a server everyone can access Each person clones her own working copy Makes a local copy of the repo You ll always work off of this copy The version control system syncs the repo and working copy (with your help) Working copy Repository git Working copy

REPOSITORY Can create the repository anywhere Can be on the same computer that you re going to work on, which might be ok for a personal project where you just want rollback protection But, usually you want the repository to be robust: On a computer that s up and running 24/7 Everyone always has access to the project On a computer that has a redundant file system No more worries about that hard disk crash wiping away your project! We ll use CSE GitLab very similar to GitHub but tied to CSE accounts and authentication

VERSION CONTROL COMMON ACTIONS Most common commands: add / commit / push pull integrate changes from your working copy into the repository integrate changes into your working copy from the repository pull Repository git push Working copy

VERSION CONTROL UPDATING FILES In a bit more detail: You make some local changes, test them, etc., then git add tell git which changed files you want to save in repo git commit save all files you ve add ed in the local repo copy as an identifiable update git push synchronize with the GitLab repo by pushing local committed changes pull Repository git push Working copy

VERSION CONTROL COMMON ACTIONS (CONT.) Other common commands: add, rm Repository add or delete a file in the working copy just putting a new file in your working copy does not add it to the repo! still need to commit to make permanent pull git push Working copy

THIS QUARTER We distribute starter code by adding it to your GitLab repo. You retrieve it with git clone the first time then git pull for later assignments You will write code using Eclipse You turn in your files by adding them to the repo, committing your changes, and eventually pushing accumulated changes to GitLab You turn in an assignment by tagging your repo and pushing the tag to GitLab Do this after committing and pushing your files You will validate your homework by SSHing onto attu, cloning your repo, and running an Ant build file

331 VERSION CONTROL create/push Repository Working copy for grading clone/pull Working copy commit/push add

Your Local Repository

LINKS TO DETAILED SETUP AND USAGE INSTRUCTIONS All References https://courses.cs.washington.edu/courses/cse331/18sp/#resources http://courses.cs.washington.edu/courses/cse331/18wi/docs.html Machine Setup: Java, Eclipse, SSH https://courses.cs.washington.edu/courses/cse331/18sp/machine-setup.html Editing, Compiling, Running, and Testing Programs https://courses.cs.washington.edu/courses/cse331/18sp/tools/editingcompiling.html Eclipse Reference https://courses.cs.washington.edu/courses/cse331/18sp/tools/eclipse_refere nce.html Version Control Git (includes setting up gitlab locally) https://courses.cs.washington.edu/courses/cse331/18sp/tools/versioncontrol.html https://gitlab.cs.washington.edu/help/ssh/readme.md Assignment Submission https://courses.cs.washington.edu/courses/cse331/18sp/tools/turnin.html

DEVELOPER TOOLS Remote access Eclipse and Java versions Version Control

331 VERSION CONTROL Your main repository is on GitLab Only clone once (unless you re working in a lot of places) Don t forget to add/commit/push files! Do this regularly for backup even before you re done! Check in your work!

GIT BEST PRACTICES Add/commit/push your code EARLY and OFTEN!!! You really, really, really don t want to deal with merge conflicts Keep your repository up-to-date all the time Use the combined Commit and Push tool in Eclipse Do not rename folders and files that we gave you this will mess up our grading process and you could get a bad score Use the repo only for the homework Adding other stuff (like notes from lecture) may mess up our grading process

Live Demo of Setup!

HW 3 Many small exercises to get you used to version control and tools and a Java refresher More information on homework instructions: https://courses.cs.washington.edu/courses/cse3 31/18sp/hws/hw03/hw3.html Cloning your repo: Instructions Committing changes: Instructions How you turn in your assignments Updating changes: Instructions How you retrieve new assignments

Turning in HW3 Instructions Create a hw3-final tag on the last commit and push the tag to the repo (this can and should be done in Eclipse) You can push a new hw3-final tag that overwrites the old one if you realize that you still need to make changes (Demo) In Eclipse, just remember to check the correct checkboxes to overwrite existing tags But keep track of how many late days you have left! After the final commit and tag pushed, remember to log on to attu and run ant validate

Turning in HW3 Add/commit/push your final code Create a hw3-final tag on the last commit and push the tag to the repo (this can and should be done in Eclipse) You can push a new hw3-final tag that overwrites the old one if you realize that you still need to make changes (Demo) In Eclipse, just remember to check the correct checkboxes to overwrite existing tags But keep track of how many late days you have left! After the final commit and tag pushed, remember to log on to attu and run ant validate

Ant Validate What will this do? You start with a freshly cloned copy of your repo and do git checkout hw3-final to switch to the files you intend for us to grade, then run ant validate Makes sure you have all the required files Make sure your homework builds without errors Passes specification and implementation tests in the repository Note: this does not include the additional tests we will use when grading This is just a sanity check that your current tests pass

Ant Validate How do you run ant validate? Has to be done on attu from the command line since that is the environment your grading will be done on Do not use the Eclipse ant validate build tool! Be sure to use a fresh copy of your repo, and discard that copy when you re done If you need to fix things, do it in your primary working copy (eclipse)

Ant Validate How do you run ant validate? Steps Log into attu via SSH In attu, checkout a brand new local copy (clone) of your repository through the command-line Note: Now, you have two local copies of your repository, one on your computer through Eclipse and one in attu May need to create an SSH key on attu and add to GitLab: instructions Go to the hw folder which you want to validate through the cd command, then switch to the hw3 tag For example: cd ~/cse331/src/hw3 git checkout hw3-final Run ant validate

Ant Validate How do you know it works? If successful, will output Build Successful at the bottom If unsuccessful, will output Build Failed at the bottom with information on why If ant validate failed, discard the validate copy of the repo on attu, fix and commit changes through eclipse, go back to attu, clone a fresh copy of the repo, and try ant validate again

ECLIPSE

WHAT IS ECLIPSE? Integrated development environment (IDE) Allows for software development from start to finish Type code with syntax highlighting, warnings, etc. Run code straight through or with breakpoints (debug) Break code Mainly used for Java Supports C, C++, JavaScript, PHP, Python, Ruby, etc. Alternatives NetBeans, Visual Studio, IntelliJ IDEA

ECLIPSE SHORTCUTS Shortcut Ctrl + D Alt + Shift + R Ctrl + Shift + O Ctrl + / Ctrl + Shift + F Ctrl + Space Ctrl + S Purpose Delete an entire line Refactor (rename) Clean up imports Toggle comment Make my code look nice Autocomplete Save (Eclipse does not autosave!)

ECLIPSE and Java Get Java 8 Important: Java separates compile and execution, eg: javac Example.java produces Example.class Both compile and execute have to be the same Java! Please use Eclipse Oxygen, Eclipse for Java Developers Instructions: http://courses.cs.washington.edu/courses/cse331/18wi/tool s/workingathome.html#step_1

ECLIPSE DEBUGGING (if time) System.out.println() works for debugging It s quick It s dirty Everyone knows how to do it but there are drawbacks What if I m printing something that s null? What if I want to look at something that can t easily be printed (e.g., what does my binary search tree look like now)? Eclipse s debugger is powerful if you know how to use it

ECLIPSE DEBUGGING

ECLIPSE DEBUGGING Double click in the grey area to the left of your code to set a breakpoint. A breakpoint is a line that the Java VM will stop at during normal execution of your program, and wait for action from you.

ECLIPSE DEBUGGING Click the Bug icon to run in Debug mode. Otherwise your program won t stop at your breakpoints.

ECLIPSE DEBUGGING Controlling your program while debugging is done with these buttons

ECLIPSE DEBUGGING Play, pause, stop work just like you d expect

ECLIPSE DEBUGGING Step Into Steps into the method at the current execution point if possible. If not possible then just proceeds to the next execution point. If there s multiple methods at the current execution point step into the first one to be executed.

ECLIPSE DEBUGGING Step Over Steps over any method calls at the current execution point. Theoretically program proceeds just to the next line. BUT, if you have any breakpoints set that would be hit in the method(s) you stepped over, execution will stop at those points instead.

ECLIPSE DEBUGGING Step Out Allows method to finish and brings you up to the point where that method was called. Useful if you accidentally step into Java internals (more on how to avoid this next). Just like with step over though you may hit a breakpoint in the remainder of the method, and then you ll stop at that point.

ECLIPSE DEBUGGING Enable/disable step filters There s a lot of code you don t want to enter when debugging, internals of Java, internals of JUnit, etc. You can skip these by configuring step filters. Checked items are skipped.

ECLIPSE DEBUGGING Stack Trace Shows what methods have been called to get you to current point where program is stopped. You can click on different method names to navigate to that spot in the code without losing your current spot.

ECLIPSE DEBUGGING Variables Window Shows all variables, including method parameters, local variables, and class variables, that are in scope at the current execution spot. Updates when you change positions in the stackframe. You can expand objects to see child member values. There s a simple value printed, but clicking on an item will fill the box below the list with a pretty format. Some values are in the form of ObjectName (id=x), this can be used to tell if two variables are refering to the same object.

ECLIPSE DEBUGGING Variables that have changed since the last break point are highlighted in yellow. You can change variables right from this window by double clicking the row entry in the Value tab.

ECLIPSE DEBUGGING Variables that have changed since the last break point are highlighted in yellow. You can change variables right from this window by double clicking the row entry in the Value tab.

ECLIPSE DEBUGGING There s a powerful right-click menu. See all references to a given variable See all instances of the variable s class Add watch statements for that variables value (more later)

ECLIPSE DEBUGGING Show Logical Structure Expands out list items so it s as if each list item were a field (and continues down for any children list items)

ECLIPSE DEBUGGING Breakpoints Window Shows all existing breakpoints in the code, along with their conditions and a variety of options. Double clicking a breakpoint will take you to its spot in the code.

ECLIPSE DEBUGGING Enabled/Disabled Breakpoints Breakpoints can be temporarily disabled by clicking the checkbox next to the breakpoint. This means it won t stop program execution until reenabled. This is useful if you want to hold off testing one thing, but don t want to completely forget about that breakpoint.

ECLIPSE DEBUGGING Hit count Breakpoints can be set to occur less-frequently by supplying a hit count of n. When this is specified, only each n-th time that breakpoint is hit will code execution stop.

ECLIPSE DEBUGGING Conditional Breakpoints Breakpoints can have conditions. This means the breakpoint will only be triggered when a condition you supply is true. This is very useful for when your code only breaks on some inputs! Watch out though, it can make your code debug very slowly, especially if there s an error in your breakpoint.

ECLIPSE DEBUGGING Disable All Breakpoints You can disable all breakpoints temporarily. This is useful if you ve identified a bug in the middle of a run but want to let the rest of the run finish normally. Don t forget to re-enable breakpoints when you want to use them again.

ECLIPSE DEBUGGING Break on Java Exception Eclipse can break whenever a specific exception is thrown. This can be useful to trace an exception that is being translated by library code.

ECLIPSE DEBUGGING Expressions Window Used to show the results of custom expressions you provide, and can change any time. Not shown by default but highly recommended.

ECLIPSE DEBUGGING Expressions Window Used to show the results of custom expressions you provide, and can change any time. Resolves variables, allows method calls, even arbitrary statements 2+2 Beware method calls that mutate program state e.g. stk1.clear() or in.nextline() these take effect immediately

ECLIPSE DEBUGGING Expressions Window These persist across projects, so clear out old ones as necessary.