Program Function and Purpose 1-2 Hacks
Hacks for Program Function and Purpose (Week 5)
Notes
Video 1
- Purpose of computing innovations: solve problems or pursue interests through creative expression
- Better understanding of the purpose = better program
- Examples:
- Apps
- Games
- Social Media
- Business
- Productivity
- Physical devices
- Computers
- Smart Phones/tablets
- Smart devices
- Wearables
- Systems
- E-commerce
- Cloud Services
- Apps
- Guidelines for creating a purpose
- Why does the innovation exist?
- What problem(s) does it solve?
- What does it allow us to do that we previously could not?
- Example:
- Social media applications
- Allows users to connect from a distance and archive activities
- E-commerce
- Allows users to save time and money by shopping online
- Digital Assistant Device
- Allows users to control the device hands-free, making it safer while driving or more convenient when multitasking
- Social media applications
Video 2
- Program input: data sent to a computer for processing by a program
- May be tactile (touch), audio, visual, text (+ numerical values), etc…
- An event is associated with an action and supplies input data to a program
- Events can be generated in a variety of ways
- pressing a key
- clicking the mouse
- tapping the screen
- etc…
- Outputs usually depend on the input to a program
- Event-driven programming allows for program statements to be executed when triggered instead of through the sequential flow of control
- Input can come from a user or other programs
- Program outputs are any data sent from a program to a device
- comes in a variety of forms
- tactile
- audio
- visual
- text
- etc…
- comes in a variety of forms
- Program output is usually based on a program’s input or prior state
- Example: internal values)
- Examples:
- Smart phone inputs: tactile (tapping screen), audio (hey siri), visual (facial recognition), text (password)
- Laptop: tactile (trackpad/mouse controls), text (password/keyboard actions)
- Gaming console: tactile (controller buttons), visual (virtual reality)
- Most programs are written in an event driven environment
- “Events” are triggered by some action, which usually sends input to the program
- Examples of “events”
- mouse clicks
- screen taps/swipes
- physical button clicks
- keyboard entries
- audio trigger (keyword or phrase such as “Hey Siri” or “Ok Google”)
- Why is input important to a program?
- Input usually affects the output
- Types of outputs
- Visual, audio, tactile, text, etc…
- Examples
- Smart phone/tablet (visual, screen change), (audio), (tactile, vibrations), (text, notifications, etc…)
- Laptop (visual), (audio), (text)
- Gaming console (visual), (audio), (tactile), (text)
- How events work
- an action triggers an event
- action may be initiated by the user or another program/device
- Program “jumps” to the code segment according to the event:
- Code segment is executed
- Output is triggered by the code segment (or additional events are triggered)
- Event-driven programs are not always “in order”
- Code segments are executed as they are called (according to the events triggered)
Video 3
- A computer program is a collection of statements that are executed according to the rules of the programming language
- A program is a collection of program statements that performs a specific task when run by a computer. A program is often referred to as software
- A code segment is a collection of program statements that is part of a program
- A program needs to work for a variety of inputs and situations
- The behavior of a program is how a program functions during execution and is often described by how a user interacts with it
- A program can be described broadly by what it does, or in more detail by both what the program does and how the program statements accomplish this function
- What is a program?
- A collection of statements
- Statement: single command (tells computer what to do)
- Group of statements: code segment
- Code segments are executed according to the rules of the programming language
- A collection of statements
- Example:
- Code segment:
- Text:
min <– aList[1]
FOR EACH item IN aList
{
IF ( item < min)
{
min <– item
}
}
DISPLAY (“The minimum number in the list is”)
DISPLAY (min)
- Assigns aList[1] to variable min
- Looks at each number in the list individually and repeats the code in the segment for each item in the list
- If item is less than min (which is first number in the list)
- Then, assign that item to be the new minimum
- Repeat for all items in list
- If item is less than min (which is first number in the list)
- Displays message to the user about the lowest number that it found in the list
- WHAT DOES THIS SEGMENT DO?
- finds the minimum value in a list
- Things to think about:
- How can we make this work with a variety of different lists, such as:
- numbers out of order
- negative numbers
- large numbers
- decimals
- How can we make this work with a variety of different lists, such as:
- This code segment can be inserted into a larger program
- Text:
min <– aList[1]
- Code segment:
- Describing a code segment
- State what it does (makes it easier for someone to use that segment in a larger program)
- Good idea to include how it does what it does
- Explain in detail how the code functions
- Someone could expand upon it
Proof of MCQ completion
Hacks
- Yes, we are going to make an academic organizer
- Yes
- Hopefully
- Yes
- Yes