Prof. Ken Regis Institute for Computer Engineering Florida State University Oktober 2002Prof. Ken Regis - FIT 1-11.

Slides:



Advertisements
Similar presentations
How Are Algorithms Developed?
Advertisements

Computers Are Your Future
Introduction to Programming
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
زبانهای برنامه سازی برنامه سازی پیشرفته ارائه دهنده دکتر سيد امين حسيني E.mail: Home page:
 Introduction to Programming History of programming.
Programming Creating programs that run on your PC
Program Development and Programming Languages
An Introduction to Programming with C++ Fifth Edition Chapter 1 An Introduction to Programming.
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Chapter 2- Visual Basic Schneider1 Chapter 2 Problem Solving.
The Program Design Phases
PRE-PROGRAMMING PHASE
Intro to Programming CST JavaScript. Objectives Define software Identify the different types of software Differentiate the different types of programming.
Programming Concepts and Languages Chapter 12 – Computers: Understanding Technology, 3 rd edition 1November
CS 331, Principles of Programming Languages Introduction.
© Paradigm Publishing Inc Chapter 12 Programming Concepts and Languages.
Introduction to Programming Prof. Rommel Anthony Palomino Department of Computer Science and Information Technology Spring 2011.
Programming Languages CPS120: Introduction to Computer Science Lecture 5.
Introduction to Programming Lecture Number:. What is Programming Programming is to instruct the computer on what it has to do in a language that the computer.
Chapter 8 High-Level Programming Languages (modified by Erin Chambers)
CC111 Lec#5: Program Development 1 Program Development and Programming Languages Lecture 4 Reference :Understanding Computers Chapter 13.
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
Alexandria University Faculty of Science Computer Science Department Introduction to Programming (CS 102) C++ Programminhg.
COMPUTER PROGRAMMING Source: Computing Concepts (the I-series) by Haag, Cummings, and Rhea, McGraw-Hill/Irwin, 2002.
Evolution of Programming Languages Generations of PLs.
COMPUTER PROGRAMS AND LANGUAGES Chapter 4. Developing a computer program Programs are a set (series) of instructions Programmers determine The instructions.
PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.
CPS120 Introduction to Computer Programming The Programming Process.
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.
INTRODUCTION TO COMPUTING CHAPTER NO. 04. Programming Languages Program Algorithms and Pseudo Code Properties and Advantages of Algorithms Flowchart (Symbols.
Chapter 12 Computer Programming. Chapter Contents Chapter 12: Computer Programming 2  Section A: Programming Basics  Section B: Procedural Programming.
CPS120: Introduction to Computer Science Decision Making in Programs.
Copyright © Prentice Hall Programming and Languages Chapter 14 Telling the Computer What to Do.
Control Structures CPS120: Introduction to Computer Science Lecture 5.
CS 331, Principles of Programming Languages Chapter 1.
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
Chapter 12: Computer Programming 1 Computer Programming Chapter 12.
Programming Languages
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
The Hashemite University Computer Engineering Department
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.
PROGRAMMING FUNDAMENTALS INTRODUCTION TO PROGRAMMING. Computer Programming Concepts. Flowchart. Structured Programming Design. Implementation Documentation.
CPS120: Introduction to Computer Science Session 5.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Software Engineering Algorithms, Compilers, & Lifecycle.
PROGRAMMING (1) LECTURE # 1 Programming and Languages: Telling the Computer What to Do.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
Programming Logic and Design Seventh Edition Chapter 1 An Overview of Computers and Programming.
OCR A Level F453: High level languages Programming techniques a. identify a variety of programming paradigms (low-level, object- oriented,
CSCI-235 Micro-Computer Applications
Introduction of Programming Languages
Programming Concepts and Languages
Developing Applications
Computer Programming.
Unit# 9: Computer Program Development
CPS120: Introduction to Computer Science
Chapter 2- Visual Basic Schneider
Chapter 2- Visual Basic Schneider
How Are Algorithms Developed?
and Program Development
Principles of Programming Languages
Tonga Institute of Higher Education IT 141: Information Systems
Tonga Institute of Higher Education IT 141: Information Systems
Basic Concepts of Algorithm
CPS120: Introduction to Computer Science
Programming Logic and Design Eighth Edition
Presentation transcript:

Prof. Ken Regis Institute for Computer Engineering Florida State University Oktober 2002Prof. Ken Regis - FIT 1-11

Ken Regis

Why learn about programming? programming teaches you how to solve problems programming helps you be more precise (doesn’t win you many friends though!) why did the computer scientist stay in the shower forever? the instructions on the shampoo said “lather, rinse, repeat!” programming gets you more out of your computer you may not be programming, but knowing a little bit about Computer Science and knowing a little bit about Programming will help you work with people who do

Programs A program is a set of step-by-step instructions that directs the computer to do the tasks you want it to do and produce the results you want.

You have already programmed! You wrote complex formulas in Excel =$D5*EKSP(-LN(2)*E$4/$C5) You used SQL to talk to databases SELECT * FROM contacts WHERE age BETWEEN 18 AND 35; You programmed in MATLAB function r = fz(x) global M p w1; X = [cos(x), sin(x); -sin(x), cos(x)]; r1 = M' - p' - X*w1'; r = r1'*r1;

Programming Programming consists of two steps: algorithmic design (the architects) coding (the construction workers) Programming requires: a programming language to express your ideas a set of tools to design, edit, and debug your code either a compiler to translate your programs to machine code a machine to run the executable code or an interpreter to translate and execute your program

Programming Languages A programming language is a set of rules that provides a way of telling a computer what operations to perform.

Levels of Programming Languages Machine language Assembly Language High Level Languages Fourth Generation Languages (4GL) Fifth Generation Languages (5GL)

Machine Languages different for each computer processor

Assembly Languages different for each computer processor mainproc pay mov ax, dseg mov ax, 0b00h add ax, dx mov a1, b1 mul b1, ax mov b1, 04h

High-Level Languages Higher Level Languages Use traditional programming logic where the programming instructions tell the computer what to do and how to perform the required operations. 4GLs Use high-level English-like instructions to specify what to do, not how to do it.

Types of high level Programming Languages Procedure-oriented languages Object-oriented languages Event-driven languages Declarative languages

Procedure-Oriented Languages FORTRAN COBOL Pascal C Ada

OOED Languages Object-oriented languages Smalltalk C++ Ada 95 Java C# Event-driven languages Visual Basic most Visual languages

Declarative languages (5GL) Functional(?): Lisp, Scheme, SML Also called applicative Everything is a function Logic: Prolog Based on mathematical logic Rule- or Constraint-based

Language Family Tree

Lots more Languages There are many programming languages out there specification languages, e.g. Z, UML document languages, e.g. LaTeX, Postscript command languages, e.g. csh, MATLAB query languages, e.g. SQL Scripting languages, e.g. Perl, Python, JavaScript, VBScript, ASP, PHP, …

What determines a “good” language Formerly: Run-time performance (Computers were more expensive than programmers) Now: Life cycle (human) cost is more important Ease of designing, coding Debugging Maintenance Reusability FADS

Why so many? Why does some people speak French? Most important: the choice of paradigm, and therefore language, depends on how humans best think about the problem Other considerations: efficiency compatibility with existing code availability of tools

What can a program do? A program can only instruct a computer to: Sequence Calculate Store data Compare and branch Iterate or Loop Write Output Read Input

Sequence Control Structures Sequence control structures direct the order of program instructions. The fact that one instruction follows another—in sequence—establishes the control and order of operations.

Calculate A program can instruct a computer to perform mathematical operations. Add 1 to Counter

Store A program will often instruct a computer to store intermediate results. Place 1 in Counter

Compare and Branch A program can instruct a computer to compare two items and do something based on a match or mismatch which, in turn, redirect the sequence of programming instructions. There are two forms: IF-THEN IF-THEN-ELSE

IF-THEN Test condition p falsetrue Entry Exit True statement a

IF-THEN-ELSE falsetrue Entry Exit Test condition p “true” statement a “false” statement a

Iterate A program loop is a form of iteration. A computer can be instructed to repeat instructions under certain conditions. No

Iteration Control Structures Iteration control structures are looping mechanisms. Loops repeat an activity until stopped. The location of the stopping mechanism determines how the loop will work: Leading decisions Trailing decisions

Leading Decisions If the stop is at the beginning of the iteration, then the control is called a leading decision. The command DO WHILE performs the iteration and places the stop at the beginning.

DO WHILE Loop No Yes Entry Exit Test condition p Loop statement a

Trailing Decisions If the stop is at the end of the iteration, the control mechanism is called a trailing decision. The command DO UNTIL performs the iteration and puts the stop at the end of the loop.

DO UNTIL Loop Loop statement a NoYes Entry Test condition p Exit

Programs are Solutions to Problems Programmers arrive at these solutions by using one or more of these devices: Logic flowcharts Pseudocode Structured Programming UML Object Oriented Programming

Logic Flowcharts These represent the flow of logic in a program and help programmers “see” program design.

Terminator. Shows the starting and ending points of the program. A terminator has flowlines in only one direction, either in (a stop node) or out (a start node). Data Input or Output. Allows the user to inputdata and results to be displayed. Processing. Indicates an operation performed by the computer, such as a variable assignment or mathematical operation. Decision. The diamond indicates a decision structure. A diamond always has two flowlines out. One flowlineout is labeled the “yes” branch and the other is labeled the “no” branch. Predefined Process. One statement denotes a group of previously defined statements. For instance, “Calculate m!” indicates that the program executes the necessary commands to compute m factorial. Connector. Connectors avoid crossing flowlines, making the flowchart easier to read. Connectors indicate where flowlines are connected. Connectors come in pairs, one with a flowline in and the other with a flowline out. Off-page connector. Even fairly small programs can have flowcharts that extend several pages. The off-page connector indicates the continuation of the flowchart on another page. Just like connectors, off-page connectors come in pairs. Flowline. Flowlines connect the flowchart symbols and show the sequence of operations during the program execution. Common Flowchart Symbols

Start sum=0 Input price sum=sum+price More items? vat=sum x 0.25 total=sum+vat Output sum, vat, and total Stop No Yes Flowchart for a Cash Register Program

Psuedocode This device is not visual but is considered a “first draft” of the actual program. Pseudocode is written in the programmer’s native language and concentrates on the logic in a program— not the syntax of a programming language.

sum=0 While More items do Input price sum=sum+price End While vat=sum x 0.25 total=sum+vat Output sum, vat, total Pseudocode for a Cash Register Program

Structured Programming Structured program languages lend themselves to flowcharts and pseudocode. Structured programming languages work best where the instructions have been broken up into small, manageable parts.

Object Oriented Programming Everything is an object A program is a bunch of objects telling each other what to do by sending messages Each object has its own memory made up of other objects Every object has a type All objects of a particular type can receive the same messages (Alan Kay)

The object concept An object is an encapsulation of data and behaviour, modeled after real-world objects An object is an instance of an abstract data type An abstract data type is implemented via a class An object has identity (a unique reference) state (also called characteristics) behaviour Behaviour is implemented via methods Methods are often implemented using structured programming An objects methods and state are access via dot notation I.e document.write(“Hello World”)

Analyze the problem Design the solution algorithm Design the user interface Write the code Test and debug the program Complete the documentation The Program Development Cycle

Programming and Debugging Write code Syntax Rules of the language Logic Order of execution of various parts of the program

Programming and Debugging Programming Errors Syntax error Misuse of syntax e.g., typing fer instead of for Logic errors Unintended operation of program e.g., Infinite loop

Programming and Debugging Debugging Tracing and resolving errors in a program Coined by Admiral Grace Hopper Moth short-circuited a relay “bug” in the system Removed it  system “debugged” Not an exact science – more a black art Human against evil machine!

So really, why learn about programming? Programmers make lots of money. Programming really is fun. Programming is very intellectually rewarding. Programming makes you feel superior to other people. Programming gives you complete control over an innocent, vulnerable machine, which will do your evil bidding with a loyalty not even your pet dog can rival.