หลักการโปรแกรม เพื่อแก้ปัญหาโดยใช้คอมพิวเตอร์

Slides:



Advertisements
Similar presentations
CS101: Introduction to Computer programming
Advertisements

Chapter 2: Problem Solving
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
© Janice Regan Problem-Solving Process 1. State the Problem (Problem Specification) 2. Analyze the problem: outline solution requirements and design.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
Department of Computer Science University of Maryland, College Park
Chapter 1 Principles of Programming and Software Engineering.
Programming Fundamentals (750113) Ch1. Problem Solving
Chapter 1 Program Design
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
1 Chapter 2 Problem Solving Techniques INTRODUCTION 2.2 PROBLEM SOLVING 2.3 USING COMPUTERS IN PROBLEM SOLVING : THE SOFTWARE DEVELOPMENT METHOD.
BPC.1 Basic Programming Concepts
Data Structures and Programming.  John Edgar2.
The Art of Programming Top-Down Design. The Art of Problem Solving The art of problem solving is the transformation of an English description of a problem.
Computer Science I CS rmaclin
1 L07SoftwareDevelopmentMethod.pptCMSC 104, Version 8/06 Software Development Method Topics l Software Development Life Cycle Reading l Section 1.4 – 1.5.
Introduction 01_intro.ppt
Chapter 2: Problem Solving
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
Chapter 2: Problem Solving
Managing the development and purchase of information systems (Part 1)
Chapter 3: Completing the Problem- Solving Process and Getting Started with C++ Introduction to Programming with C++ Fourth Edition.
1 C++ Plus Data Structures Nell Dale Chapter 1 Software Engineering Principles Modified from the Slides made by Sylvia Sorkin, Community College of Baltimore.
Software Development Cycle What is Software? Instructions (computer programs) that when executed provide desired function and performance Data structures.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
The Development Process Problem Solving. Problem Solving - Dr. Struble 2 What Is Asked of Computer Programmers? Input Transformation Output Write a computer.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
CMSC 1041 Algorithms II Software Development Life-Cycle.
UHD::3320::CH121 DESIGN PHASE Chapter 12. UHD::3320::CH122 Design Phase Two Aspects –Actions which operate on data –Data on which actions operate Two.
กระบวนการแก้ปัญหาด้วย คอมพิวเตอร์ 3 พฤษภาคม :00-17:00.
Programming Life Cycle Problem analysisunderstand the problem Requirements definition specify what program will do High- and low-level designhow it meets.
Introduction to Problem Solving. Steps in Programming A Very Simplified Picture –Problem Definition & Analysis – High Level Strategy for a solution –Arriving.
Chapter 2: General Problem Solving Concepts
1 Ch. 1: Software Development (Read) 5 Phases of Software Life Cycle: Problem Analysis and Specification Design Implementation (Coding) Testing, Execution.
The basics of the programming process The development of programming languages to improve software development Programming languages that the average user.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
1 Program Planning and Design Important stages before actual program is written.
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Data Structure Introduction Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2010.
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
Chapter 1 Software Engineering Principles. Problem analysis Requirements elicitation Software specification High- and low-level design Implementation.
The Hashemite University Computer Engineering Department
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Alexandria University Faculty of Science Computer Science Department Introduction to Programming C++
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
Evolution of C and C++ n C was developed by Dennis Ritchie at Bell Labs (early 1970s) as a systems programming language n C later evolved into a general-purpose.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
Introduction to Problem Solving Programming is a problem solving activity. When you write a program, you are actually writing an instruction for the computer.
Algorithms and Problem Solving
Algorithms II Software Development Life-Cycle.
System Design.
Principles of Programming and Software Engineering
Programming Problem steps must be able to be fully & unambiguously described Problem types; Can be clearly described Cannot be clearly described (e.g.
Introduction to Problem Solving
Problem Solving Techniques
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
Chapter 1 Introduction(1.1)
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
Chapter 2- Visual Basic Schneider
Understanding Problems and how to Solve them by using Computers
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
Presentation transcript:

หลักการโปรแกรม เพื่อแก้ปัญหาโดยใช้คอมพิวเตอร์ อ.จรรยา สายนุ้ย CS.313 ภาควิชาวิทยาการคอมพิวเตอร์

Outline Problem Solving Programming Principle Definition Strategies Techniques Tools Approach Programming Principle Programming Language Programming Design Programming Paradigms

Problem Solving Definition ................................................................................................................................ Problem Solving The process of transforming the description of a problem into the solution of that problem by using own knowledge of the problem domain and be relying on the ability to select and use appropriate problem solving strategies, techniques and tools

Problem Domain sciences : mathematics , statistics , chemistry , physics, biology business : inventory , accounting education : registration , evaluation banking : ATM , loaning , report others : restaurant , transportation , hotel , department store

Problem Solving Strategies (Algorithm Design Techniques) Divide and Conquer Dynamic Programming Greedy Algorithms etc.

Problem Solving Techniques Top-down Stepwise Refinement Structured Programming Modular Design Bottom-up Approach Recursion

Problem Solving Tools Pseudo Code Flowchart Programming Languages Editor Debugger

Problem Solving Approach Software Development Method or Software Life Cycle Use computers in problem solving consists of 6 steps : Requirement Specification Analysis Design Implementation Testing And Verification Documentation

Software Life Cycle Requirement Specification what the problem is what is needed to solve what the solution should provide any constraints and special conditions to concern depend on familiarity with the problem domain

Software Life Cycle Analysis Input Output Constraints/Conditions Formulas

Software Life Cycle Design 3.1 Algorithm design 3.2 Data design definition requirement strategy techniques 3.2 Data design Input/Output Process Types Representation Structure manipulation

Software Life Cycle Algorithm Definition 3.1 Algorithm design Algorithm : a method of solution described as a sequence of steps to be performed in a specific logical order.

Software Life Cycle Satisfied Requirements : 3.1 Algorithm design Unambiguousness Generality Correctness Finiteness

Software Life Cycle Representation Strategy 3.1 Algorithm design Pseudocoding Flowcharting HIPO Chart

Software Life Cycle 3.1 Algorithm design Greedy Method Techniques Greedy Method Divide and Conquer Dynamic Programming Backtracking Algorithms etc.

Software Life Cycle 3.2 Data design Input/Output Process Types : constant/variables ,global/local Representation: number , text , etc. Structure: array, file , queue , tree , etc. Manipulation: operators , functions ................................................................................................................................................................ ................................................................................................................................................ ......................................................................................................................................................................... .....................................................................................................................................................

Software Life Cycle Implementation or Coding Programming Languages writability readability modifiability reusability

Software Life Cycle Implementation or Coding Important as designing skill programming is the art of designing efficient algorithms to meet requirements Programming errors Debugging techniques Strategies for defensive Programming

Software Life Cycle Implementation or Coding Programming Errors design errors syntax/compilation errors linker errors run-time errors warning diagnostic message

Software Life Cycle Implementation or Coding Debugging techniques The ability to debug programs is another problem-solving skill that is as important as the ability to design programs Debugging is the process of finding and correcting errors in computer programs

Software Life Cycle Implementation or Coding Debugging techniques design errors quite difficult to debug , no error message , incorrect output sometimes incorrect formula , wrong program logic , inappropriate data type careful review in analysis and design , use variety of testing data

Software Life Cycle Implementation or Coding Debugging techniques syntax/compilation errors Detect by compilers Something missing / undeclared var. Easy , just correct error sources warning diagnostic message Strange but can still proceed Unreferenced var. Get rid of causes or ignore

Software Life Cycle Implementation or Coding Debugging techniques linker errors Some errors prevent the linker to create the executable module Function prototypes do not match their definitions solution: correct prototypes

Software Life Cycle Implementation or Coding Debugging techniques run-time/execution errors while executing , difficult to debug, abnormal termination divide by zero , type mismatch ,index is out of range, domain error trace/step watch some variables’ value , error handling

Software Life Cycle Strategies for defensive correction : errors debug Implementation or Coding Strategies for defensive correction : errors debug defence : to prevent abnormal termination /errors preparing to manage errors if (a < o) { … } using exception handler

Software Life Cycle Testing And Verification program verification the process of ensuring that a program meets user requirements one of the techniques that can be used for program verification is program testing

Software Life Cycle Testing And Verification program testing the process of executing a program to demonstrate its correctness testing methods test data testing modules : driver , stub top-down testing bottom-up testing blackbox .vs. whitebox

Software Life Cycle: Example Requirement Specification เขียนโปรแกรมหาระยะทางระหว่างจุด 2 จุดคือ (x1 ,y1 ) และ (x2 ,y2 ) สูตรคือ

Software Life Cycle : Example Analysis Input: integer x1 , y1 , x2 และ y2 Output : float & positive value Formulas :

Software Life Cycle: Example Algorithm Design Pseudocode Read x1 , y1 , x2 , y2 dist = sqrt((x1 - x2)2 + (y1 - y2)2) Write dist end

Software Life Cycle: Example Implementation or Coding #include <stdio.h> #include <math.h> void main() { int x1, x2, y1, y2; float dist; scanf(“%d %d %d %d”, &x1, &y1, &x2, &y2); dist = sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); printf(“distance = %f\n”,dist); }

Software Life Cycle: Example Testing And Verification verifying: compile and debug data test: 3 0 0 4 output: 5.0

Software Life Cycle Documentation System documentation Program documentation User documentation

Software Life Cycle Documentation System documentation Context Diagram Dataflow Diagram Database Design : E-R diagram , Relational model , Data dictionary System modules/flowchart

Software Life Cycle Documentation Program documentation Flowchart / Pseudocode Program Listing Sufficient in-program : comment , indentation

Software Life Cycle Documentation User documentation Interfaces Input Examples Output Examples Error messages : causes & effect

Programming Principles Programming Languages Program Design Programming Paradigms

Programming Languages Why programming languages ? to enable the user to enlist the help of a computer in solving problems in the domain of interest to enable the user to bridge the gap between problem and machine domain

Program Design modular design stepwise refinement top-down approach bottom-up approach stepwise refinement structured programming etc.

Programming paradigms imperative paradigm functional paradigm logic paradigm object-oriented paradigm

Practice make perfect