Lecture 3. Miscellaneous Ruby and Testing
|
|
- Grant Bradford
- 6 years ago
- Views:
Transcription
1 Lecture 3 Miscellaneous Ruby and Testing 1
2 Sublime Text Guide I wrote a quick Sublime Text Guide that will help with Rubocop offenses It ll walk you through: Using spaces instead of tabs by default Using 2 spaces in Ruby files by default Enabling Rubocop linting within the Sublime Text Sublime Text Setup Guide 2
3 Homework 1 Grades were released on Saturday! TAs provided feedback on best practices, but did not take off points Keep the comments in mind for future homework assignments Any questions? 3
4 Homework 2 README was missing a significant part of the assignment It has since been updated Homework 2 will be due on 11:59pm If you submit it tonight, I will give you a free late day to use on any homework assignment this semester Any questions? 4
5 Remaining Office Hours Wednesday, 4:30-5:30pm, Moore 100 (Jackie) Wednesday, 8-9pm, Harrison Mezz (Sanjana) Thursday, 6-7pm, Moore 100 (Jackie) 5
6 Variables 6
7 Constants Constants are like variables, but their value should never be changed once they re initialized Constants start with a capital letter By convention, they should be in all upper case and words separated with underscores (e.g. THIS_CONSTANT) Ruby will allow you to change them, but it will output a warning They can also be accessed from another class or module with :: class Foo BAR = 'bar' end p Foo::BAR #=> "bar" 7
8 Global Variables Denoted with a $ in the beginning of the identifier They are (mostly) accessible throughout the entire Ruby program and never go out of scope They generally provide information you would want regardless of where in the program you are For example, $0 returns the name of the startup file for the program Never use global variables unless you know what you're doing 8
9 Regular Expressions 9
10 Regular Expressions Regular expressions are usually instantiated with // from the Regexp class They match patterns For example, if I wanted to find all letters in the string 'h3l1o w0r1d' 'h3l1o w0r1d'.scan(/[a-za-z]/) #=> ["h", "l", "o", "w", "r", "d"] 10
11 Methods to Match String#scan Returns an array of all matches Returns an empty array if there is no match String#=~ or Regexp#=~ This will return the index where the regexp matches the string It will return nil if there is no match '123hello' =~ /[a-z]/ #=> 3 String#match or Regexp#match This will return a MatchData object, which can be used to get more information about the match It will return nil if there is no match 11
12 How to Write Regexes Use Rubular to experiment You can match with: literal characters dot wildcard characters character classes 12
13 Literal Characters The exact characters in the regular expression are used 'abcd' =~ /a/ #=> 0 'abcd' =~ /ab/ #=> 0 'abcd' =~ /ac/ #=> nil 13
14 Dot Wildcard Characters Using a dot (.) will match any character in that place To match for an actual dot, escape it with the backslash (\) This is also true for any other special characters 'cat bat data'.scan(/.at/) #=> ["cat", "bat", "dat"] 'hello. so. nooooo'.scan(/o\./) #=> ["o.", "o."] 14
15 Character Classes A list of characters can be denoted with square brackets ([]) 'cat bat sat'.scan(/[cb]at/) #=> ["cat", "bat"] These also support ranges with a hyphen (-), so to search for all letters, use [a-za-z] 'hi bye'.scan(/[a-za-z]/) #=> ["h", "i", "b", "y", "e"] 15
16 Common Character Classes Instead of constantly typing out the same list of character classes, some have been abstracted into special characters For example: \s denotes whitespace characters \d denotes digits '12hello3'.scan(/\d/) #=> ["1", "2", "3"] 16
17 Callable Objects 17
18 What is a block? Blocks are one of the few things in Ruby that are not objects They are the pieces of code between the do and end keywords or {} 3.times do print 'hi' end 18
19 How to use blocks in your own methods? Denote an argument as a block by starting it with a & Each method can only have one block passed to it It must be the last argument in the method signature The block can be called with either the call method or the yield keyword in a method The yield keyword is faster and preferred in methods Outside of methods, use the call method def call_block(&block) block.call yield end call_block { print 'hi ' } #=> "hi hi " 19
20 Passing arguments to blocks Arguments can be passed to the call method or yield keyword Parameters are then defined in the block between pipelines This should not surprise you since you've already had plenty of practice with this with iterators def call_block(&block) yield('foo') end call_block { elem p elem } #=> "foo" 20
21 Blocks are flexible It turns out that any number of arguments can be passed to blocks If too many arguments are passed in, the remaining arguments are "thrown away If not enough arguments are passed in, the remaining parameters are defaulted to nil 21
22 def call_block(&block) yield yield(1, 2) end call_block do x p x end #=> nil #=> 1 22
23 What is a proc? A Proc is a type of callable object, and it is instantiated with a block It can be instantiated with Proc.new or the proc method The proc method is preferred Since it can be stored in variables, it is a good way to write blocks in a DRY way a_proc = Proc.new { p 'foo' } a_proc.call #=> "foo" another_proc = proc { p 'bar' } another_proc.call #=> "bar" 23
24 Passing procs to methods The & denotes the argument is a proc a_proc = proc { p 'foo' } def bar(&baz) yield end bar(&a_proc) #=> "foo" 24
25 What does & do? It turns out that it: denotes the argument stands in for a block calls to_proc on the argument When to_proc is called on a proc, the proc simply returns itself However, any class that defines to_proc that returns a proc can be used instead of a block One important example is symbols. Calling to_proc on a symbol returns a proc of the method with the same "name" as the symbol 'hello'.split.map { c c.upcase }.join #=> "HELLO" 'hello'.split.map(&:upcase).join #=> "HELLO" 25
26 Procs as closures A closure is a function that retains the environment from which it is created In the case of Ruby, a proc is a closure def foo(x) y = 10 proc { z x + y + z } end first_proc = foo(1) second_proc = foo(2) first_proc.call(3) #=> 14 second_proc.call(3) #=> 15 26
27 What is a lambda? A lambda is a special type of proc (it's still an instance of the Proc class) It will throw an error when an incorrect number of arguments is passed in Lambdas treat explicit return keywords differently In lambdas, a return will just exit the lambda In normal procs, a return will exit the method it's in or throw an error if not in a method 27
28 def foo puts 'calling lambda' lam = lambda { return } lam.call puts 'calling proc' pr = proc { return } pr.call puts 'all done!' end foo #=> "calling lambda" #=> "calling proc" 28
29 Instantiating Lambdas The lambda method with a block can be used similar to the proc method for procs Another way is to use ->, the stabby lambda Stabby lambdas are preferred for one liner lambdas The lambda method is preferred for multi-line lambdas Lambdas are generally preferred over procs unless a specific behavior of normal procs is desired 29
30 Stabby Lambda Pass a block to the stabby lambda to instantiate the lambda Pass arguments in parentheses to the stabby lambda to pass them to the block lam1 = -> { p 'hi' } lam1.call #=> "hi" lam2 = ->(x, y) { x + y } lam2.call(1, 2) #=> 3 30
31 Command Line Interface (CLI) Use the gets method to collect user input It will have a newline character at the end, so call strip on the output of gets to get rid of it This is useful for writing dynamic command line interfaces 31
32 Testing 32
33 Why do we write tests? Fewer bugs in new and existing code Allows us to refactor They make for good documentation Improve design 33
34 Test-Driven Development (TDD) Process that involves writing tests before writing the code being tested Steps: 1. Write a very small test for code that does not yet exist 2. Run the test & watch it fail 3. Write just enough code to make the test pass 4. Once the test passes, refactor as necessary 5. Repeat 34
35 Behavior Driven Development (BDD) Started as a way to better understand & explain TDD Puts the focus on behavior instead of structure BDD Triad: Given some context When some event occurs Then I expect some outcome 35
36 Ruby Testing Frameworks MiniTest RSpec* Cucumber 36
37 RSpec RSpec is a productive Ruby test framework Made of three independent gems: rspec-core: overall test harness that runs the specs rspec-expectations: provides a readable, powerful, syntax for checking properties of your code rspec-mocks: makes it easy to isolate code being tested from rest of system 37
38 Getting Started gem install rspec Run bundle exec rspec --init Creates.rspec file Creates spec/spec_helper.rb which contains configuration options 38
39 Specs RSpec tests are known as specs Short for specifications because they specify the desired behavior of your code Specs are placed in files ending in _spec.rb inside of the spec directory Serve two purposes: Documenting what the object can do Checking that the object does what it s supposed to 39
40 Example Groups You create example groups in RSpec using describe Define what you re testing & keep related specs together You can pass a string, Ruby class, module, or object to describe describe User do describe '#valid?' do... end end 40
41 Examples You create examples using it You pass it the description of the behavior you re specifying describe User do describe '#valid?' do it 'returns true if the user is valid' do... end end end 41
42 context context is an alias for describe Groups together examples that are related to a shared situation or condition Useful to improve readability describe User do describe '#valid?' do context 'when the user is valid' do it 'returns true' end end end 42
43 Expectations Expectations are like assertions in other languages Each RSpec example should contain at least one expectation Most of the time they should contain exactly one Primary goal is for clarity 43
44 Expect You create expectations using expect Parts: Subject what s being tested Matcher an object specifying what you expect to be true about the subject Custom Failure Message this is optional expect(post.valid?).to be true, 'post is not valid' expect(post.valid?).not_to be true, 'post is valid' 44
45 Matchers Similar to regular expressions Define a category of objects that meet a certain specification Examples: be_empty eq( ) raise_error include( ) be_kind_of( ) List of Built-in Matchers 45
46 Running Specs Run tests by running the rspec command Formatters: You can optionally use formatters for displaying the output of your specs Documentation formatter: rspec --format documentation Running specific directories/files: rspec spec/{directory/file_name} 46
47 Hooks Great for common setup/teardown code Types specify when the hook should run relative to the examples: before will run before every example after will run after every example around will sandwich an example Scope allows you to specify how often the hook gets run :each this is the default, will run once per example :all will run once per example group 47
48 Hooks before(:each) do... end after(:all) do... end around do... example.run... end 48
49 let let binds a name to the result of a computation They are useful for assigning variables at the beginning of an example group describe User do describe '#valid?' do let(:user) { User.new } it 'is not valid without a name' do expect(user.valid?).to be_false end end end 49
50 Resources RSpec API Documentation RSpec Built-In Matchers Better Specs 50
51 Test Coverage We want to strive for 100% test coverage Can use the simplecov gem to check coverage To use: Add gem 'simplecov', require: false to testing group of Gemfile and bundle install Add the following at top of spec/spec_helper.rb: require 'simplecov SimpleCov.start Run tests and open coverage/index.html file in browser 51
52 Homework 3 You will be writing tests for a Command Line Interface Grading: Correctness (15 pts) You must have at least one test for every method All tests must pass You must reach 100% test coverage Style (5 pts) Best Practices (5 pts) These will be both Ruby Best Practices & testing Best Practices 52
53 Homework
54 Next Week: Ruby on Rails! 54
Lecture 3. Miscellaneous Ruby and Testing 1 / 40
Lecture 3 Miscellaneous Ruby and Testing 1 / 40 Homework 1 Grades were released! TAs provided feedback on best practices, but did not take off points Keep the comments in mind for future assignments! Any
More informationLecture 3. Miscellaneous Ruby and Testing 1 / 48
Lecture 3 Miscellaneous Ruby and Testing 1 / 48 Homework 1 Grades were released! TAs provided feedback on best practices, but did not take off points Keep the comments in mind for future assignments! Any
More informationLecture 1. Basic Ruby 1 / 61
Lecture 1 Basic Ruby 1 / 61 What does this do? 3.times do print 'Hello, world!' end 2 / 61 Why Ruby? Optimized for programmer happiness Used for Ruby on Rails Very popular web framework 3 / 61 Course Policies
More informationLecture 2. Object Orientation
Lecture 2 Object Orientation 1 Homework 0 Grades Homework 0 grades were returned earlier this week Any questions? 2 Homework 1 Homework 1 is due tonight at 11:59pm You will be graded on: Correctness: 15
More informationLecture 2. Object Orientation 1 / 50
Lecture 2 Object Orientation 1 / 50 Homework 1 Homework 1 was due last night You will be graded on: Correctness: 15 points (passing all RSpec tests) Style: 5 points (having no Rubocop style offenses) Best
More informationLecture 4. Ruby on Rails 1 / 52
Lecture 4 Ruby on Rails 1 / 52 Homeworks 2 & 3 Grades were released for homework 2 Homework 3 was due last night Everyone got a style freebie since my default setup ignores spec files and I didn't change
More informationThis tutorial will show you, how to use RSpec to test your code when building applications with Ruby.
About the Tutorial RSpec is a unit test framework for the Ruby programming language. RSpec is different than traditional xunit frameworks like JUnit because RSpec is a Behavior driven development tool.
More informationLecture 2. Object Orientation 1 / 51
Lecture 2 Object Orientation 1 / 51 Homework 1 Homework 1 was due at noon You will be graded on: Correctness: 15 points (passing all RSpec tests) Style: 5 points (having no Rubocop style offenses) Best
More informationRSPec Documentation. 4. Scenario Testing Examples of OAR REST APIs using Rspec
RSPec Documentation Contents: 1. Introduction to Rspec - Installing Rspec Gem (Getting Started) - Terminology used in Rspec 2. Writing Simple Rspec Tests 3. Running Rspec Testfiles 4. Scenario Testing
More informationThis tutorial will show you, how to use RSpec to test your code when building applications with Ruby.
About the Tutorial RSpec is a unit test framework for the Ruby programming language. RSpec is different than traditional xunit frameworks like JUnit because RSpec is a Behavior driven development tool.
More informationRuby: Introduction, Basics
Ruby: Introduction, Basics Computer Science and Engineering College of Engineering The Ohio State University Lecture 4 Ruby vs Java: Similarities Imperative and object-oriented Classes and instances (ie
More informationRSpec Core Project: RSpec Core 2.11 Publisher: RSpec. Issues. Open Feedback Dialog. rspec-core provides the structure for RSpec code examples:
Open Feedback Dialog Project: RSpec Core 2.11 Publisher: RSpec RSpec Core 2.11 rspec-core provides the structure for RSpec code examples: describe Account do it "has a balance of zero when first opened"
More informationCucumber 3.0 and Beyond
Cucumber 3.0 and Beyond Thomas Haver tjhaver@gmail.com Abstract Cucumber is a tool that supports Behavior Driven Development (BDD), a software development practice that promotes collaboration. Cucumber
More informationBasic Syntax - First Program 1
Python Basic Syntax Basic Syntax - First Program 1 All python files will have extension.py put the following source code in a test.py file. print "Hello, Python!";#hello world program run this program
More informationYour First Ruby Script
Learn Ruby in 50 pages Your First Ruby Script Step-By-Step Martin Miliauskas @mmiliauskas 1 Your First Ruby Script, Step-By-Step By Martin Miliauskas Published in 2013 by Martin Miliauskas On the web:
More informationOverview of the Ruby Language. By Ron Haley
Overview of the Ruby Language By Ron Haley Outline Ruby About Ruby Installation Basics Ruby Conventions Arrays and Hashes Symbols Control Structures Regular Expressions Class vs. Module Blocks, Procs,
More informationChapter 1 Summary. Chapter 2 Summary. end of a string, in which case the string can span multiple lines.
Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of
More informationLecture 4. Ruby on Rails 1 / 49
Lecture 4 Ruby on Rails 1 / 49 Client-Server Model 2 / 49 What is it? A client (e.g. web browser, phone, computer, etc.) sends a request to a server Request is an HTTP request Stands for HyperText Transfer
More informationRuby: Introduction, Basics
Ruby: Introduction, Basics Computer Science and Engineering College of Engineering The Ohio State University Lecture 4 Ruby vs Java: Similarities Imperative and object-oriented Classes and instances (ie
More informationLecture 27. Lecture 27: Regular Expressions and Python Identifiers
Lecture 27 Lecture 27: Regular Expressions and Python Identifiers Python Syntax Python syntax makes very few restrictions on the ways that we can name our variables, functions, and classes. Variables names
More informationCIS192: Python Programming
CIS192: Python Programming Introduction Harry Smith University of Pennsylvania January 18, 2017 Harry Smith (University of Pennsylvania) CIS 192 Lecture 1 January 18, 2017 1 / 34 Outline 1 Logistics Rooms
More informationRegular Expressions. Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl)
Regular Expressions Regular expressions are a powerful search-and-replace technique that is widely used in other environments (such as Unix and Perl) JavaScript started supporting regular expressions in
More informationCSE 413 Programming Languages & Implementation. Hal Perkins Winter 2019 Ruby Containers, Blocks, and Procs
CSE 413 Programming Languages & Implementation Hal Perkins Winter 2019 Ruby Containers, Blocks, and Procs CSE413 Winter 2019 1 The Plan Ruby container data structures Blocks and control structures (iterators,
More informationPython I. Some material adapted from Upenn cmpe391 slides and other sources
Python I Some material adapted from Upenn cmpe391 slides and other sources Overview Names & Assignment Data types Sequences types: Lists, Tuples, and Strings Mutability Understanding Reference Semantics
More information\n is used in a string to indicate the newline character. An expression produces data. The simplest expression
Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of
More informationRuby: Introduction, Basics
Ruby: Introduction, Basics Computer Science and Engineering College of Engineering The Ohio State University Lecture 3 Ruby vs Java: Similarities Imperative and object-oriented Classes and instances (ie
More informationCS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square)
CS 4240: Compilers and Interpreters Project Phase 1: Scanner and Parser Due Date: October 4 th 2015 (11:59 pm) (via T-square) Introduction This semester, through a project split into 3 phases, we are going
More informationCSSE2002/7023 The University of Queensland
CSSE2002 / CSSE7023 Semester 1, 2016 Assignment 1 Goal: The goal of this assignment is to gain practical experience with data abstraction, unit testing and using the Java class libraries (the Java 8 SE
More informationIntro. Scheme Basics. scm> 5 5. scm>
Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if
More informationCS 2112 Lab: Regular Expressions
October 10, 2012 Regex Overview Regular Expressions, also known as regex or regexps are a common scheme for pattern matching regex supports matching individual characters as well as categories and ranges
More informationContents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual
Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual Contents 1 Introduction...2 2 Lexical Conventions...2 3 Types...3 4 Syntax...3 5 Expressions...4 6 Declarations...8 7 Statements...9
More informationFSASIM: A Simulator for Finite-State Automata
FSASIM: A Simulator for Finite-State Automata P. N. Hilfinger Chapter 1: Overview 1 1 Overview The fsasim program reads in a description of a finite-state recognizer (either deterministic or non-deterministic),
More informationCS 5142 Scripting Languages
CS 5142 Scripting Languages 10/25/2012 Ruby 1 Outline Ruby Martin Hirzel 2 About Ruby Invented 1995 by Yokihiro Matz Matsumoto Influenced by SmallTalk Everything is an object (even e.g., integers) Blocks
More informationCS 115 Lecture 4. More Python; testing software. Neil Moore
CS 115 Lecture 4 More Python; testing software Neil Moore Department of Computer Science University of Kentucky Lexington, Kentucky 40506 neil@cs.uky.edu 8 September 2015 Syntax: Statements A statement
More informationCIS192 Python Programming. Robert Rand. August 27, 2015
CIS192 Python Programming Introduction Robert Rand University of Pennsylvania August 27, 2015 Robert Rand (University of Pennsylvania) CIS 192 August 27, 2015 1 / 30 Outline 1 Logistics Grading Office
More informationLearning Language. Reference Manual. George Liao (gkl2104) Joseanibal Colon Ramos (jc2373) Stephen Robinson (sar2120) Huabiao Xu(hx2104)
Learning Language Reference Manual 1 George Liao (gkl2104) Joseanibal Colon Ramos (jc2373) Stephen Robinson (sar2120) Huabiao Xu(hx2104) A. Introduction Learning Language is a programming language designed
More informationDr. Sarah Abraham University of Texas at Austin Computer Science Department. Regular Expressions. Elements of Graphics CS324e Spring 2017
Dr. Sarah Abraham University of Texas at Austin Computer Science Department Regular Expressions Elements of Graphics CS324e Spring 2017 What are Regular Expressions? Describe a set of strings based on
More information61A Lecture 3. Friday, September 5
61A Lecture 3 Friday, September 5 Announcements There's plenty of room in live lecture if you want to come (but videos are still better) Please don't make noise outside of the previous lecture! Homework
More informationThere are two ways to use the python interpreter: interactive mode and script mode. (a) open a terminal shell (terminal emulator in Applications Menu)
I. INTERACTIVE MODE VERSUS SCRIPT MODE There are two ways to use the python interpreter: interactive mode and script mode. 1. Interactive Mode (a) open a terminal shell (terminal emulator in Applications
More informationcc -o build/test_translate build/test_translate.o b... $
EECS 211 Homework 2 Winter 2019 Due: Partners: January 24, 2019 at 11:59 PM No; must be completed by yourself Purpose The goal of this assignment is to get you programming with strings, iteration, and
More informationMore Examples. Lex/Flex/JLex
More Examples A FORTRAN-like real literal (which requires digits on either or both sides of a decimal point, or just a string of digits) can be defined as RealLit = (D + (λ. )) (D *. D + ) This corresponds
More informationThe PCAT Programming Language Reference Manual
The PCAT Programming Language Reference Manual Andrew Tolmach and Jingke Li Dept. of Computer Science Portland State University September 27, 1995 (revised October 15, 2002) 1 Introduction The PCAT language
More information1 CS580W-01 Quiz 1 Solution
1 CS580W-01 Quiz 1 Solution Date: Wed Sep 26 2018 Max Points: 15 Important Reminder As per the course Academic Honesty Statement, cheating of any kind will minimally result in receiving an F letter grade
More informationCMSC 330: Organization of Programming Languages. Ruby Regular Expressions
CMSC 330: Organization of Programming Languages Ruby Regular Expressions 1 String Processing in Ruby Earlier, we motivated scripting languages using a popular application of them: string processing The
More informationB The SLLGEN Parsing System
B The SLLGEN Parsing System Programs are just strings of characters. In order to process a program, we need to group these characters into meaningful units. This grouping is usually divided into two stages:
More informationFundamentals of Programming Session 4
Fundamentals of Programming Session 4 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2011 These slides are created using Deitel s slides, ( 1992-2010 by Pearson Education, Inc).
More informationCMSC330 Fall 2016 Midterm #1 2:00pm/3:30pm
CMSC330 Fall 2016 Midterm #1 2:00pm/3:30pm Name: Discussion Time: 10am 11am 12pm 1pm 2pm 3pm TA Name (Circle): Alex Austin Ayman Brian Damien Daniel K. Daniel P. Greg Tammy Tim Vitung Will K. Instructions
More informationCLIP - A Crytographic Language with Irritating Parentheses
CLIP - A Crytographic Language with Irritating Parentheses Author: Duan Wei wd2114@columbia.edu Yi-Hsiu Chen yc2796@columbia.edu Instructor: Prof. Stephen A. Edwards July 24, 2013 Contents 1 Introduction
More informationCSE 341, Autumn 2015, Ruby Introduction Summary
CSE 341, Autumn 2015, Ruby Introduction Summary Disclaimer: This lecture summary is not necessarily a complete substitute for atting class, reading the associated code, etc. It is designed to be a useful
More informationSmalltalk: developed at Xerox Palo Alto Research Center by the Learning Research Group in the 1970 s (Smalltalk-72, Smalltalk-76, Smalltalk-80)
A Bit of History Some notable examples of early object-oriented languages and systems: Sketchpad (Ivan Sutherland s 1963 PhD dissertation) was the first system to use classes and instances (although Sketchpad
More informationThis page covers the very basics of understanding, creating and using regular expressions ('regexes') in Perl.
NAME DESCRIPTION perlrequick - Perl regular expressions quick start Perl version 5.16.2 documentation - perlrequick This page covers the very basics of understanding, creating and using regular expressions
More information12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.
Java How to Program, 9/e Education, Inc. All Rights Reserved. } Java application programming } Use tools from the JDK to compile and run programs. } Videos at www.deitel.com/books/jhtp9/ Help you get started
More informationCSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP. Dan Grossman Winter 2013
CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP Dan Grossman Winter 2013 Ruby logistics Next two sections use the Ruby language http://www.ruby-lang.org/ Installation / basic usage
More informationSoftware Engineering 2 (SWT2)
Software Engineering 2 (SWT2) Chapter 5: Getting you ready for the project - Lego Scrum Exercise, Git, Infrastructure, your next week, Testing, PO presentation - Agenda 2 Lego Scrum Exercise Git Project
More informationSCHEME AND CALCULATOR 5b
SCHEME AND CALCULATOR 5b COMPUTER SCIENCE 6A July 25, 203 In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs,
More informationCSE : Python Programming
CSE 399-004: Python Programming Lecture 2: Data, Classes, and Modules January 22, 2007 http://www.seas.upenn.edu/~cse39904/ Administrative things Teaching assistant Brian Summa (bsumma @ seas.upenn.edu)
More informationKU Compilerbau - Programming Assignment
716.077 KU Compilerbau - Programming Assignment Univ.-Prof. Dr. Franz Wotawa, Birgit Hofer Institute for Software Technology, Graz University of Technology April 20, 2011 Introduction During this semester
More informationCS 230 Programming Languages
CS 230 Programming Languages 09 / 20 / 2013 Instructor: Michael Eckmann Today s Topics Questions/comments? Continue Regular expressions Matching string basics =~ (matches) m/ / (this is the format of match
More informationRuby logistics. CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP. Ruby: Not our focus. Ruby: Our focus. A note on the homework
Ruby logistics CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP Dan Grossman Autumn 2018 Next two sections use the Ruby language http://www.ruby-lang.org/ Installation / basic usage
More informationTest First Software Development
Test First Software Development Jacob Kristhammar Roger Schildmeijer D04, Lund Institute of Technology, Sweden {d04jk d04rp}@student.lth.se 2008-02-06 Abstract In this in-depth study we will try to explain
More informationc) Comments do not cause any machine language object code to be generated. d) Lengthy comments can cause poor execution-time performance.
2.1 Introduction (No questions.) 2.2 A Simple Program: Printing a Line of Text 2.1 Which of the following must every C program have? (a) main (b) #include (c) /* (d) 2.2 Every statement in C
More informationTypescript on LLVM Language Reference Manual
Typescript on LLVM Language Reference Manual Ratheet Pandya UNI: rp2707 COMS 4115 H01 (CVN) 1. Introduction 2. Lexical Conventions 2.1 Tokens 2.2 Comments 2.3 Identifiers 2.4 Reserved Keywords 2.5 String
More informationCSE 401/M501 18au Midterm Exam 11/2/18. Name ID #
Name ID # There are 7 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed books, closed notes,
More informationBoredGames Language Reference Manual A Language for Board Games. Brandon Kessler (bpk2107) and Kristen Wise (kew2132)
BoredGames Language Reference Manual A Language for Board Games Brandon Kessler (bpk2107) and Kristen Wise (kew2132) 1 Table of Contents 1. Introduction... 4 2. Lexical Conventions... 4 2.A Comments...
More informationCS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG
CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 3: SEP. 13TH INSTRUCTOR: JIAYIN WANG 1 Notice Reading Assignment Chapter 1: Introduction to Java Programming Homework 1 It is due this coming Sunday
More informationCSC Web Programming. Introduction to JavaScript
CSC 242 - Web Programming Introduction to JavaScript JavaScript JavaScript is a client-side scripting language the code is executed by the web browser JavaScript is an embedded language it relies on its
More informationThe Three Rules. Program. What is a Computer Program? 5/30/2018. Interpreted. Your First Program QuickStart 1. Chapter 1
The Three Rules Chapter 1 Beginnings Rule 1: Think before you program Rule 2: A program is a human-readable essay on problem solving that also executes on a computer Rule 3: The best way to improve your
More informationCMSC201 Computer Science I for Majors
CMSC201 Computer Science I for Majors Lecture 09 Strings Last Class We Covered Lists and what they are used for Getting the length of a list Operations like append() and remove() Iterating over a list
More informationCS164: Programming Assignment 2 Dlex Lexer Generator and Decaf Lexer
CS164: Programming Assignment 2 Dlex Lexer Generator and Decaf Lexer Assigned: Thursday, September 16, 2004 Due: Tuesday, September 28, 2004, at 11:59pm September 16, 2004 1 Introduction Overview In this
More informationImproving Coverage Analysis
Improving Coverage Analysis 1 Ryan Davis Coding professionally 25 years, 16 years Ruby Founder, Seattle.rb; First & Oldest Ruby Brigade Author: minitest, flog, flay, debride, ruby_parser, etc. ~114 million
More informationGBIL: Generic Binary Instrumentation Language. Language Reference Manual. By: Andrew Calvano. COMS W4115 Fall 2015 CVN
GBIL: Generic Binary Instrumentation Language Language Reference Manual By: Andrew Calvano COMS W4115 Fall 2015 CVN Table of Contents 1) Introduction 2) Lexical Conventions 1. Tokens 2. Whitespace 3. Comments
More informationa b c d a b c d e 5 e 7
COMPSCI 230 Homework 9 Due on April 5, 2016 Work on this assignment either alone or in pairs. You may work with different partners on different assignments, but you can only have up to one partner for
More informationCS1 Lecture 3 Jan. 18, 2019
CS1 Lecture 3 Jan. 18, 2019 Office hours for Prof. Cremer and for TAs have been posted. Locations will change check class website regularly First homework assignment will be available Monday evening, due
More informationA First Look at ML. Chapter Five Modern Programming Languages, 2nd ed. 1
A First Look at ML Chapter Five Modern Programming Languages, 2nd ed. 1 ML Meta Language One of the more popular functional languages (which, admittedly, isn t saying much) Edinburgh, 1974, Robin Milner
More informationWatir-Webdriver Cucumber Automation Framework Setup Guide
Watir-Webdriver Cucumber Automation Framework Setup Guide Documentation version table: Document updating summary. Version Date Date Created 1.0 08/05/15 Index Page 1 November 18, 2015 Table of Contents
More informationGetting Started. Office Hours. CSE 231, Rich Enbody. After class By appointment send an . Michigan State University CSE 231, Fall 2013
CSE 231, Rich Enbody Office Hours After class By appointment send an email 2 1 Project 1 Python arithmetic Do with pencil, paper and calculator first Idle Handin Help room 3 What is a Computer Program?
More informationIntroduction to Ruby. SWEN-250 Personal Software Engineering
Introduction to Ruby SWEN-250 Personal Software Engineering A Bit of History Yukihiro "Matz'' Matsumoto Created a language he liked to work in. Been around since mid-90s. Caught on in early to mid 00s.
More informationDEBUGGING TIPS. 1 Introduction COMPUTER SCIENCE 61A
DEBUGGING TIPS COMPUTER SCIENCE 61A 1 Introduction Every time a function is called, Python creates what is called a stack frame for that specific function to hold local variables and other information.
More informationWriting a Lexer. CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Monday, February 6, Glenn G.
Writing a Lexer CS F331 Programming Languages CSCE A331 Programming Language Concepts Lecture Slides Monday, February 6, 2017 Glenn G. Chappell Department of Computer Science University of Alaska Fairbanks
More informationJava Bytecode (binary file)
Java is Compiled Unlike Python, which is an interpreted langauge, Java code is compiled. In Java, a compiler reads in a Java source file (the code that we write), and it translates that code into bytecode.
More informationBEHAVIOR DRIVEN DEVELOPMENT BDD GUIDE TO AGILE PRACTICES. Director, Strategic Solutions
BEHAVIOR DRIVEN DEVELOPMENT BDD GUIDE TO AGILE PRACTICES Presenter: Joshua Eastman Director, Strategic Solutions ABOUT THE SPEAKER Josh has over seven years of experience as an accomplished software testing
More informationIntroduction to C CMSC 104 Spring 2014, Section 02, Lecture 6 Jason Tang
Introduction to C CMSC 104 Spring 2014, Section 02, Lecture 6 Jason Tang Topics History of Programming Languages Compilation Process Anatomy of C CMSC 104 Coding Standards Machine Code In the beginning,
More informationCS1 Lecture 3 Jan. 22, 2018
CS1 Lecture 3 Jan. 22, 2018 Office hours for me and for TAs have been posted, locations will change check class website regularly First homework available, due Mon., 9:00am. Discussion sections tomorrow
More informationLanguage Reference Manual
TAPE: A File Handling Language Language Reference Manual Tianhua Fang (tf2377) Alexander Sato (as4628) Priscilla Wang (pyw2102) Edwin Chan (cc3919) Programming Languages and Translators COMSW 4115 Fall
More informationAccelerating Information Technology Innovation
Accelerating Information Technology Innovation http://aiti.mit.edu/program/philippines-summer-2012/ Philippines Summer 2012 Lecture 1 Introduction to Python June 19, 2012 Agenda About the Course What is
More informationRegex Guide. Complete Revolution In programming For Text Detection
Regex Guide Complete Revolution In programming For Text Detection What is Regular Expression In computing, a regular expressionis a specific pattern that provides concise and flexible means to "match"
More informationCSE 413 Spring Introduction to Ruby. Credit: Dan Grossman, CSE341
CSE 413 Spring 2011 Introduction to Ruby Credit: Dan Grossman, CSE341 Why? Because: Pure object-oriented language Interesting, not entirely obvious implications Interesting design decisions Type system,
More informationSTATS 507 Data Analysis in Python. Lecture 2: Functions, Conditionals, Recursion and Iteration
STATS 507 Data Analysis in Python Lecture 2: Functions, Conditionals, Recursion and Iteration Functions in Python We ve already seen examples of functions: e.g., type()and print() Function calls take the
More informationThere are two ways to use the python interpreter: interactive mode and script mode. (a) open a terminal shell (terminal emulator in Applications Menu)
I. INTERACTIVE MODE VERSUS SCRIPT MODE There are two ways to use the python interpreter: interactive mode and script mode. 1. Interactive Mode (a) open a terminal shell (terminal emulator in Applications
More informationTesting Frameworks (MiniTest)
Testing Frameworks (MiniTest) Computer Science and Engineering College of Engineering The Ohio State University Lecture 20 MiniTest and RSpec Many popular testing libraries for Ruby MiniTest (replaces
More informationCSE : Python Programming
CSE 399-004: Python Programming Lecture 11: Regular expressions April 2, 2007 http://www.seas.upenn.edu/~cse39904/ Announcements About those meeting from last week If I said I was going to look into something
More informationCMSC201 Computer Science I for Majors
CMSC201 Computer Science I for Majors Lecture 09 Strings Last Class We Covered Lists and what they are used for Getting the length of a list Operations like append() and remove() Iterating over a list
More informationCS Unix Tools & Scripting
Cornell University, Spring 2014 1 February 7, 2014 1 Slides evolved from previous versions by Hussam Abu-Libdeh and David Slater Regular Expression A new level of mastery over your data. Pattern matching
More informationFull file at C How to Program, 6/e Multiple Choice Test Bank
2.1 Introduction 2.2 A Simple Program: Printing a Line of Text 2.1 Lines beginning with let the computer know that the rest of the line is a comment. (a) /* (b) ** (c) REM (d)
More informationIPCoreL. Phillip Duane Douglas, Jr. 11/3/2010
IPCoreL Programming Language Reference Manual Phillip Duane Douglas, Jr. 11/3/2010 The IPCoreL Programming Language Reference Manual provides concise information about the grammar, syntax, semantics, and
More informationStructure and Interpretation of Computer Programs
CS 6A Spring 203 Structure and Interpretation of Computer Programs Final Solutions INSTRUCTIONS You have 3 hours to complete the exam. The exam is closed book, closed notes, closed computer, closed calculator,
More informationHere's an example of how the method works on the string "My text" with a start value of 3 and a length value of 2:
CS 1251 Page 1 Friday Friday, October 31, 2014 10:36 AM Finding patterns in text A smaller string inside of a larger one is called a substring. You have already learned how to make substrings in the spreadsheet
More informationDocumentation for LISP in BASIC
Documentation for LISP in BASIC The software and the documentation are both Copyright 2008 Arthur Nunes-Harwitt LISP in BASIC is a LISP interpreter for a Scheme-like dialect of LISP, which happens to have
More informationThe SPL Programming Language Reference Manual
The SPL Programming Language Reference Manual Leonidas Fegaras University of Texas at Arlington Arlington, TX 76019 fegaras@cse.uta.edu February 27, 2018 1 Introduction The SPL language is a Small Programming
More informationSCHEME The Scheme Interpreter. 2 Primitives COMPUTER SCIENCE 61A. October 29th, 2012
SCHEME COMPUTER SCIENCE 6A October 29th, 202 In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write Scheme programs, we will eventually
More information