Programming for the Non-Programmer Examples of programming concepts and terms for the rest of us. Laurie Weaver

Similar documents
The name of our class will be Yo. Type that in where it says Class Name. Don t hit the OK button yet.

Shorthand for values: variables

VLOOKUP() takes three mandatory parameters and one default/optional parameter:

OrbBasic Lesson 1 Goto and Variables: Student Guide

Lecture 1: Overview

OrbBasic 1: Student Guide

Detailed instructions for video analysis using Logger Pro.

COPYRIGHTED MATERIAL. Dipping Your Toe into Python. Part I. Chapter 1: Programming Basics and Strings. Chapter 2: Numbers and Operators

Laboratory 1: Eclipse and Karel the Robot

VARIABLES. Aim Understanding how computer programs store values, and how they are accessed and used in computer programs.

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

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

This book is about using Visual Basic for Applications (VBA), which is a

Algebraic Specifications

The Dynamic Typing Interlude

Chapter 3 - Simple JavaScript - Programming Basics. Lesson 1 - JavaScript: What is it and what does it look like?

2SKILL. Variables Lesson 6. Remembering numbers (and other stuff)...

6.001 Notes: Section 15.1

(2 1) What does evaluate to? What does evaluate to? What does evaluate to?

Chapter 2 The SAS Environment

Programming Fundamentals and Python

Box It Up (A Graphical Look)

Introduction to Programming

5 R1 The one green in the same place so either of these could be green.

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0. L J Howell UX Software Ver. 1.0

Topic C. Communicating the Precision of Measured Numbers

Getting Started. Excerpted from Hello World! Computer Programming for Kids and Other Beginners

Binary, Hexadecimal and Octal number system

Week - 01 Lecture - 04 Downloading and installing Python

Mr G s Java Jive. #11: Formatting Numbers

Meeting 1 Introduction to Functions. Part 1 Graphing Points on a Plane (REVIEW) Part 2 What is a function?

Lesson 1A - First Java Program HELLO WORLD With DEBUGGING examples. By John B. Owen All rights reserved 2011, revised 2015

CSE 143 Lecture 12 Inheritance

Java Programming Fundamentals - Day Instructor: Jason Yoon Website:

Fundamentals of Programming Session 4

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Spring 2016 Howard Rosenthal

Lesson 1. Introduction to Programming OBJECTIVES

DECISION STRUCTURES: USING IF STATEMENTS IN JAVA

TI-89 Calculator Workshop #1 The Basics

Lecture Transcript While and Do While Statements in C++

How do I fix Face Mismatch or Hole in Room?

6.001 Notes: Section 8.1

News English.com Ready-to-use ESL / EFL Lessons

Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal

Win-Back Campaign- Re-Engagement Series

Part 6 - Constructing Railroad Bridges

Properties and Definitions

Slide 1 CS 170 Java Programming 1 The Switch Duration: 00:00:46 Advance mode: Auto

Clean & Speed Up Windows with AWO

Getting Started (1.8.7) 9/2/2009

(Refer Slide Time: 00:23)

Text Input and Conditionals

List Building Income

This is a book about using Visual Basic for Applications (VBA), which is a

Game keystrokes or Calculates how fast and moves a cartoon Joystick movements how far to move a cartoon figure on screen figure on screen

Introduction... 3 Introduction... 4

Mobile Development Workshop DAY 2: INTRODUCTION TO JAVA

Unit E Step-by-Step: Programming with Python

9 R1 Get another piece of paper. We re going to have fun keeping track of (inaudible). Um How much time do you have? Are you getting tired?

Welcome to Python! If you re the type of person who wants to know

UAccess ANALYTICS Next Steps: Working with Bins, Groups, and Calculated Items: Combining Data Your Way

Learn Microsoft Word Like Magic!

: Intro Programming for Scientists and Engineers Assignment 1: Turtle Graphics

MITOCW watch?v=0jljzrnhwoi

TUTORIAL FOR IMPORTING OTTAWA FIRE HYDRANT PARKING VIOLATION DATA INTO MYSQL

SEER AKADEMI LINUX PROGRAMMING AND SCRIPTINGPERL 7

Transcriber(s): Aboelnaga, Eman Verifier(s): Yedman, Madeline Date Transcribed: Fall 2010 Page: 1 of 9

Chapter 2, Part I Introduction to C Programming

COPYRIGHTED MATERIAL. Starting Strong with Visual C# 2005 Express Edition

If Statements, For Loops, Functions

CISC-124. Casting. // this would fail because we can t assign a double value to an int // variable

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

Creating SQL Tables and using Data Types

Programming Lecture 3

Quiz 1: Functions and Procedures

Boolean Expressions. Is Equal and Is Not Equal

printf( Please enter another number: ); scanf( %d, &num2);

LOOPS. Repetition using the while statement

Boolean Expressions. Is Equal and Is Not Equal

Jerry Cain Handout #5 CS 106AJ September 30, Using JSKarel

Variables, expressions and statements

LESSON 3. In this lesson you will learn about the conditional and looping constructs that allow you to control the flow of a PHP script.

How Do I Choose Which Type of Graph to Use?

Part II Composition of Functions

Proofwriting Checklist

Fundamentals of Programming. Lecture 3: Introduction to C Programming

Initial Coding Guidelines

Instructions for Using the Databases

CMSC 201 Fall 2016 Lab 09 Advanced Debugging

CMSC 201 Spring 2017 Lab 12 Recursion

Programming for Engineers Introduction to C

TUTORIAL FOR IMPORTING OTTAWA FIRE HYDRANT PARKING VIOLATION DATA INTO MYSQL

Debugging Your Python Code: For Dummies

AUTOMATOR REFERENCE MANUAL

Word Processing. 2 Monroe County Library System

Yup, left blank on purpose. You can use it to draw whatever you want :-)

Lesson 4 - Basic Text Formatting

Boardmaker 5.0 (Macintosh) Creating a Story Response Board. Introduction. Case Study. Learning Objectives

CSE 12 Abstract Syntax Trees

Animations involving numbers

Transcription:

Programming for the Non-Programmer Examples of programming concepts and terms for the rest of us Laurie Weaver

Programming for the Non-Programmer Programming and programmers can seem very mysterious to those outside of the profession. To take a peek behind this virtual curtain, we ll break down some common programming terms and practices into real-life examples At the highest level, programming is about telling a computer to perform a set of tasks and providing the computer with very precise written instructions on how to accomplish them. This entire set of instructions is the program. Programs can be written in different languages, such as Java or C++, and each language has different rules and syntax, just as English and German have different rules and syntax. Even so, all computer programming languages have some concepts in common, just as all human languages have some concepts in common. Here are a few of the concepts we ll be exploring: 1. Objects 2. Initialization 3. Code (Scripting) 4. Variables 5. Literals 6. Value 7. Syntax 8. Properties 9. Methods 10. Function Getting a computer to perform a task is somewhat like getting one s teenager to correctly set the table for company. It s not enough to just leave a note saying Set the table, please. You must be very specific. Which Objects are required? Objects are things in programming, just as they are in life. In programming, objects have two important attributes: state and behavior. State describes how they are, and behavior describes what they can do. More on these later. For table setting, the objects required might be: Dishes: State = clean, color; Behavior = break, lay Napkins: State = folded, design; Behavior = blot, lay Silverware: State = clean, metal; Behavior = cut, stab, scoop, lay Table: State = size, position; Behavior = support Chairs: State = size, position; Behavior = support Next up, to get started we need to tell the computer/teenager exactly how the state of the objects should first be when the table setting program begins. This is called initialization. Laurie Weaver 2008 all rights reserved LaurieWeaver.com 2

Here might be some of our written instructions (code) for initial table setting. Get four clean, blue dishes and place each one six inches from each corresponding chair. Smash! Inadvertent plate-break behavior! We didn t tell the program to place them on the table object six inches from the chair. Computers are quite literal. They, unlike most teenagers, will do exactly what you tell them to do. It s up to the programmer to be precise in order to avoid any and all misunderstandings. Even though computer behavior is literal, sometimes as a programmer, you use a special container in your code to stand in for a literal piece of information. These special containers are called variables. Computers know the difference between literals and variables because, in the code, you write literal information within quotation marks. Let s do an exercise to explore the difference between these two. Please write your name on something. What did you write? I would have written Laurie. Unless you are also named Laurie, you would have written a different word. In this case, name acts as the special container called variable. Remember, variables are placeholders for varying values. Each of us has a different value for our name variable. Now, please write down Name. If you wrote the letters N a m e, then you behaved as a computer would have, and literally wrote down what I asked instead of writing your name value. Notice that in the previous exercise, having quotations or not around the word name greatly changed the resulting behavior. This is an example of syntax. We have syntax in English as well. Consider the following: His dad called George. (Two guys here, Dad and George) His dad, called George (One guy here, George) Here s an example of programming syntax that is very important. Often in programming logic, we want something to happen only if both sides of a statement are equal. To check for that, the programmer uses two equal signs (==) in a row. Laurie Weaver 2008 all rights reserved LaurieWeaver.com 3

Let s examine a piece of pseudo-code to explore the vital difference in programming syntax between two equal signs (==) and one (=). If I wish the computer to display a welcome message only to those of us named Laurie, then my code might look something like this. If (name == Laurie ) then say Hi, Laurie. The first part of this code, because it contains two equal signs (==), is checking if the value of the variable name is equal to the exact literal Laurie. If so, then the code is telling the computer to display a message saying exactly Hi Laurie, because that is the literal phrase within the quotation marks. If I make a syntax mistake and only use one equal sign, I would be setting the value of name to Laurie instead of checking whether both sides of the statement are equal. Here s another example. Let s take the variable paycheck. What if we want to know as soon as our pay reaches the level of $2,500 so we can afford a vacation. We write a piece of logic to check the value of paycheck. If (paycheck == $2,500 ) then say Time to plan a vacation. If our paycheck was $1,400, we would not get the Time to plan a vacation message. The variable paycheck would NOT be equal to $2,500. But, if we made the mistake of using only one equal sign (=) in our code, we would have just said paycheck IS now $2,500 even if it was really only $1,400. Oops! To recap the importance of syntax, one equal sign (=) will set a variable to the value following it. Two equal signs (==) will check to see if both sides of the statement containing them are equal. Last but not least, we shall explore the two very important concepts mentioned previously having to do with objects: state and behavior. In programming, we can either find out about the current state of an object, or change the state of an object by getting or setting the object s properties. We tell objects to do something by calling on a set of their behaviors called methods. In the table setting example, I defined the object dishes as having states of clean and color. This means these are the properties of dishes. I can set the properties: This dish.clean = true; (I have a clean dish) Laurie Weaver 2008 all rights reserved LaurieWeaver.com 4

This dish.color = blue (I have a blue dish) I can also get the state of these properties. If (dish.clean = = false) say You need to wash the dishes! (dish.clean == false is the same as not clean) If (dish.color == yellow ) say Please use the blue dishes instead. (we are checking if the yellow dishes were used). Dish objects also were defined to have two possible behaviors, break and lay. These would be sets of special instructions for the dishes object called its methods. We write methods by defining functionality (function). function break (){ If (this dish.position == floor) then shatter } Basically, this pseudo-code is saying, if I tell the dish to break, check to see if it s on the floor. If it is, then shatter. We would call this function (tell the dish what to do) by using the syntax dish.break(). Notice the parentheses following the word break. These were also used when we defined the break function. This tells the program that it is to perform an action. Obviously, there are many, many more details to learn about programming, and some of the specifics will vary depending on the programming language you write code in. But, the main concepts we ve touched on are what programmers use every day. Most are concepts you also use every day, such as objects, syntax and properties. So, the next time a programmer is talking about programming, listen in, and you might be surprised at how much you can now understand. Laurie Weaver 2008 all rights reserved LaurieWeaver.com 5