Problem Solving (design of programs) CS140: Introduction to Computing 1 8/26/13.

Slides:



Advertisements
Similar presentations
Slides prepared by Rose Williams, Binghamton University Chapter 3 Flow of Control Loops in Java.
Advertisements

Lecture Notes 8/30/05 Program Design & Intro to Algorithms.
Chapter 2: Algorithm Discovery and Design
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Java Classes Using Java Classes Introduction to UML.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
Describe the Program Development Cycle. Program Development Cycle The program development cycle is a series of steps programmers use to build computer.
By the end of this session you should be able to...
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Algorithms & Flowchart
Structured Programming (4 Credits)
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
The Hashemite University Computer Engineering Department
1 Overview of Programming Principles of Computers.
INVITATION TO Computer Science 1 11 Chapter 2 The Algorithmic Foundations of Computer Science.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
Lecture 3: Developing Procedural Thinking (How to think like a programmer) B Burlingame 16 Feb 2016.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 1 An Introduction to Visual Basic.NET and Program Design.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
Program design Program Design Process has 2 phases:
Chapter 9: Value-Returning Functions
ICS 3UI - Introduction to Computer Science
Chapter 7 User-Defined Methods.
Programming Languages
Key Ideas from day 1 slides
Introduction To Repetition The for loop
Chapter 2: Input, Processing, and Output
Topics Introduction to Repetition Structures
ALGORITHMS AND FLOWCHARTS
Objectives Identify the built-in data types in C++
Chapter 1. Introduction to Computers and Programming
Introduction to Programming
Unit 2 Smarter Programming.
University of Central Florida COP 3330 Object Oriented Programming
Lecture 2 Introduction to Programming
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Algorithm and Ambiguity
An Introduction to Visual Basic .NET and Program Design
Introduction to Problem Solving and Programming CS140: Introduction to Computing 1 8/19/13.
Problem Solving and Programming CS140: Introduction to Computing 1 8/21/13.
Loops CS140: Introduction to Computing 1 Savitch Chapter 4 Flow of Control: Loops 9/18/13 9/23/13.
Cracking the Coding Interview
Print slides for students reference
Unit# 9: Computer Program Development
VISUAL BASIC – CHAPTER ONE NOTES An Introduction to Visual Basic
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Basics - RobotC
Topic 1: Problem Solving
Coding Concepts (Basics)
Creating your first C program
Algorithm Discovery and Design
Repetition Structures
Introduction to Algorithms and Programming
Chapter 1 Introduction(1.1)
Problem Solving Skill Area 305.1
Algorithm and Ambiguity
Programming Fundamentals (750113) Ch1. Problem Solving
Software Development Process
Week 4 Lecture-2 Chapter 6 (Methods).
Tonga Institute of Higher Education IT 141: Information Systems
Java Programming Loops
Programming Fundamentals (750113) Ch1. Problem Solving
Data Structures & Algorithms
Topics Introduction to Repetition Structures
Tonga Institute of Higher Education IT 141: Information Systems
Basic Concepts of Algorithm
CS Problem Solving and Object Oriented Programming Spring 2019
Programming Logic and Design Eighth Edition
Presentation transcript:

Problem Solving (design of programs) CS140: Introduction to Computing 1 8/26/13

Last time Design before code Computers are stupid, you are smart Variable = a name for a place to store a value Activity diagram elements Pseudo code 2

Next time If you want to take notes, get/print the slides before you come to class BRING YOUR CLICKERS 3

4 Programming is more than writing code Programming – representing a general solution to problem set in a way a machine can use, which consists of 1.Design of an Algorithm a step by step solution to a problem that completes in finite time 2.Coding – translate an algorithm into a program 3.Testing – ensure the correctness of the program 4

5 Job 1: Design developing a solution to the problem If you can’t solve the problem, you can’t write the code Use graphical representations (UML) to solve 5

6 Programs are like airplanes Airplanes On the ground (still) – Static – Easy to know what it looks like (structure) In the air – Dynamic – Flexes with wind, gravity, pilot controls, physics Programs Code (not running) – Static – Easy to know what it looks like (structure) Executing (a process) – Dynamic – Changes with input data, user control, system, rules of languages

OO Programming Break the problem into entities (space, board, game) Model the entities with classes Declare and use objects of the classes (9 spaces) 7 entity classes boundary class

8 OO Programming Code Programs are composed (written by humans) – Structural Code – Action Code – Comments – because a meaningful program is revised at a later date

Structural Code Establishes the organizational structure of programs and classes Designed using UML class diagrams 9

Action Code Implements algorithms that actually do things Mostly written inside methods Designed using flow charts / activity diagrams 10

11 UML is used to design UML = “unified modeling language” includes several diagram types, including – Class diagrams represents the structure of the program – Activity diagrams represents the activity of the program

12 UML Class Diagram Robot X Y direction forward() turn() Name of the class Values (instance variables) Actions (methods)

13 Class and Object Class is the pattern (cookie cutter) – Structure: defines the Values (instance variables) Actions (methods) – Structure: the programmer writes a class (code not executing) Object is the instance (cookie) – Action – Each object has its own copy of instance variables – Each can do the actions defined in the class in a running program

14 Big Picture NetBeans Project  program Package – a collection of classes Class – a name for a collection of values (attributes) and a collection of methods Method – the actions in a class Statements – the individual actions of a method

15 Big Picture Package Robot X Y direction forward() turn() Room length width Obstacle length width RProgram Robot Room Obstacle1 Obstacle2 Obstacle3 Begin() Each class is a file on the computer Class Method

Activity Diagram Elements ElementSymbol Start Stop Statements Branching Repetition Subprograms Order of activities 16

17 Loops: top-tested 17 Loop condition checked BEFORE the loop body Loop may execute 0 times

18 Loops: bottom-tested 18 Loop condition checked AFTER loop body execution Loop will execute AT LEAST once

19 Write a program that … Simulates the movement of a robot in a room. The robot can do these things: move forward one step (one foot), turn to the right (90°). In the room are some number of rectangular obstacles. If the robot runs into one of these objects, it can’t move forward. …

20 Paper airplanes! Step 0: partner Step 1: write the instructions for making a paper airplane on a piece of paper Step 2: give the instructions to your partner Step 3: do exactly as the instructions you received say to do (just as a computer would) Step 4: test 20

21 Find (and fix) design problems before they become code problems Play the computer – Simulate the program you have designed by following the design you wrote – Follow the design you wrote, not the one in your head Tracing / Desk-checking 21

22 Problems from Chapter 4 Write a program to read a list of nonnegative integers and to display the largest integer, the smallest integer, and the average of all integers. The user indicates the end of the input by entering a negative sentinel value that is not used in finding the largest, smallest, and average values. The average should be a value of type double so that it is computed with a fractional part. 22

23 Summary Problem solving does not involve code We’ve discussed (and practiced) the basic problem solving concepts and skills Don’t panic if this didn’t all make sense … it’s only week 2 23