SlideShare a Scribd company logo
Introduction to
 Programming
  “How to win friends
and influence computers”
Introduction To Programming (2009 2010)
Introduction To Programming (2009 2010)
A Brief History of Computers
 General purpose minions
   Orders


 Human calculators
 Mechanical calculators
 Electronic calculators

 General purpose machines
   Programs
What Is Programming
Programming is just telling a computer to do
  something,

                      BUT
Computers know very little and have no common
  sense what-so-ever, so your instructions have to
  be broken down to small, simple parts,

                     AND
Computers will do exactly what you tell them.
Introduction To Programming (2009 2010)
Basic Programming
Programming at it’s core is about two things:
  defining problems, and solving problems.

These two aspects are tightly integrated
• To solve a problem you first must clearly know
  what it is
• Clearly and completely defining a problem
  gets you a long ways towards a solution
Introduction To Programming (2009 2010)
Four Tools To Get Started
Just getting started is often the hardest part of
  the project. Before diving in to the code, do
  the design document. Four tools to help are
  –Action/Event List
  –Flow Chart
  –Data Model
  –Iterative Refinement
Action List
This is a good tool to use in applications that have
  user interaction.
Write down each action the user can take.
Add a bit of detail info to each action
• Circumstances in which the user may take the
  action (1-3 sentences, and/or list)
• What happens when they do the action (1-3
  sentences)
• What other actions this one allows and denies
  (list format)
Flow Charts
Flow charts are a very useful tool to clarify and
  define programming problems
• They delineate key points in your program
• They’re especially good for state-based
  programs, such as web applications

Don’t get too bogged down in details when
 creating a flow chart – stay high level
Data Model
A data model is a detailed description of the
  information that the application will
  manipulate.

Start with a general idea/concept, then break it
  down into smaller parts, and repeat.

Aim for having each part be a string, a number,
  or a list or collection thereof.
Iterative Refinement - the Ur-Program
The process of iterative refinement

2. Say what you want the computer to do

3. If it’s all in terms the computer will understand,
   then stop, you’re done

4. Otherwise, break each part into simpler steps

5. Go to step 2

NOTE: works for small children as well as computers
The Real World
These are important concepts, and when done right
   you end up documenting your code as you go.

                    HOWEVER…
Real-world programming often doesn’t explicitly
   involve these techniques except at high levels in the
   design document. You should definitely use them
   there, and for actual coding keep them in mind as
   fallback strategies if your stuck on a problem.
What Computers Can Do Well
What Computers Can Do Well
Doing the same things over and over
Remembering things
Mathematics, ‘regular’ and true / false
Changing actions based on conditions
Taking in information
Sending out information
What Computers Can Do Well
Doing the same things over and and Subroutines
                        Loops over
Remembering things Variables and Assignment
Mathematics, ‘regular’ and true / falseOperators
Statements
Changing actions based on conditions
                                  Conditionals


and Blocks
Taking in information
Sending out information
                                          Input
                                        Output
Statements, and Blocks
A statement is a basic instruction for the computer

Statements are executed in order, from first to last

One or more statements may be grouped together
 into a block

A block is marked by curly braces
   { and }
Loops
A loop is a special kind of statement that tells a computer
   to repeat a given set of instructions

A for-loop repeats a given number of times
   e.g. say “hi” five times:
   for (1..5) { say “hi” }

A while-loop repeats as long as a certain condition is true
   e.g. go somewhere :
   while (not arrived) { take step }
Subroutines
A subroutine, function or procedure is a block of statements
   that’s been given a name and which is executed when ever
   that name is used. Essentially, it’s a miniature sub-program
   that you can use in your larger program.

Once a function finishes, the execution returns to the place
  from which it was called.

Functions can take parameters, or arguments, which allow
  values to be sent into the block of code

Functions can return values.
Variables
A variable has a name, or identifier, and may have a
  value associated.
Associate a given value with a given variable by making
  an assignment.
Variables can be declared, which creates them without
  any value. Some languages require this.
Variable Names
MUST:
Start with a letter
Contain letters or numbers or underscores

SHOULD:
Be meaningful (often 10+ characters)
Be readable (use _ or mixCase to mark words)
Follow convention (start lower case, i, x, y)
Basic Values
Literal values:
   Numbers
       0, -3, 8.223419783
   Strings (a series of characters)
       “zero”, ”0”, “cheddar cheese”
Expressions:
   One or more values, expressions, or variables combined by operators
                              8.3 * 4.291
                                    2
                        “smoked” . “ “ . “cheddar”
   A variable used in a expression is replaced by its value
                            ingredient_count + 3
Operators
There are all the standard math operators
   + - * / % ()

The string concatenation operator combines two or more strings into
  one
   Depends on the language (often . or +)

There are many other operators too
   Boolean math
   Comparisons
   Specialized

Operators combine values and expressions into larger expressions
Conditionals
A conditional, or branch, statement executes a
  block of other statements based on whether a
  given condition is true or false

Conditions are evaluated using boolean
  operators, as well as comparisons and other
  things that are true or false
General Conditional Statement
if (condition)
   Block executed if condition is true
else if (other condition)
   Block executed if other condition is true
else
   Block executed if all conditions are false
Input and Output
Special statements get data into and out of a
  program.
  Details vary by language


Data can come from:
  keyboard, web page, mouse, file, other


Data can go to:
  screen, file, the internet, other
Comments
Comments are a way to put text in the program
  code which does not get executed. This is very
  useful for leaving notes / descriptions /
  explanations, and for testing.
Comments are usually denoted by
  # or // to comment to the end of the line
  /* to comment out multiple lines
     */
Best Practices
Always make backups of original working code before
  messing with it
Use comments to mark what you change, how, and
  when, and to keep copies of original statements
Test early, test often
Work together – more eyes means fewer bugs
Read the manual – there are great references online
Look at examples
Introduction To Programming (2009 2010)
Introduction To Programming (2009 2010)
Introduction To Programming (2009 2010)
Introduction To Programming (2009 2010)
mr.islamelhosary@gmail.com

More Related Content

PDF
notes on Programming fundamentals
PPT
Learn Programming with Livecoding.tv http://goo.gl/tIgO1I
PPT
Programming
PPTX
PPTX
Basic Computer Programming
PPTX
Computer programming
DOC
Notacd07
PPTX
What is programming what are its benefits
notes on Programming fundamentals
Learn Programming with Livecoding.tv http://goo.gl/tIgO1I
Programming
Basic Computer Programming
Computer programming
Notacd07
What is programming what are its benefits

What's hot (20)

PDF
Introduction to Computer Programming
PDF
The Programming Process
PPTX
Basic programming
PPT
Basic Programming Concept
PPTX
Introduction to programming
PPT
Intro To Programming Concepts
PDF
Graphical programming
PPT
Project
PPTX
Programming Fundamentals lecture 2
PPT
Lec 1 intro
PPT
Chapter 5( programming) answer
PPTX
Programming Fundamentals and Programming Languages Concepts
PPSX
Ic lecture8
PPTX
Interpreter
PPTX
C programming
PPTX
Algorithm and pseudo codes
PPTX
Programming Paradigm & Languages
PPTX
Chapter 5
PDF
Computer programming all chapters
PPTX
Compiler vs Interpreter-Compiler design ppt.
Introduction to Computer Programming
The Programming Process
Basic programming
Basic Programming Concept
Introduction to programming
Intro To Programming Concepts
Graphical programming
Project
Programming Fundamentals lecture 2
Lec 1 intro
Chapter 5( programming) answer
Programming Fundamentals and Programming Languages Concepts
Ic lecture8
Interpreter
C programming
Algorithm and pseudo codes
Programming Paradigm & Languages
Chapter 5
Computer programming all chapters
Compiler vs Interpreter-Compiler design ppt.
Ad

Viewers also liked (17)

PDF
Javafx Overview 90minutes
PPT
Google Summer of Code
PPT
How To Get Your First Job
PDF
Javanowandfuture Chihuahua
PPT
Develop Your Skills With Osum
PDF
I Phone Session Mufix
PDF
Javafx Overview 90minutes
PDF
Javafx Overview 90minutes
ODP
Linux Presentation
PDF
Game Programming By J2me
PPS
Linux Administration
PDF
PPT
Mufix Network Programming Lecture
PPT
PPT
Joomla Presentations
Javafx Overview 90minutes
Google Summer of Code
How To Get Your First Job
Javanowandfuture Chihuahua
Develop Your Skills With Osum
I Phone Session Mufix
Javafx Overview 90minutes
Javafx Overview 90minutes
Linux Presentation
Game Programming By J2me
Linux Administration
Mufix Network Programming Lecture
Joomla Presentations
Ad

Similar to Introduction To Programming (2009 2010) (20)

PPT
Introduction To Programming
PPT
Programming Fundamentals - Lecture 1.ppt
PPTX
Introduction to Coding
PPTX
Software fundamentals
PDF
Tutor Py
PPTX
Developing a Coding Program for Users - SWFLN Makerpalooza - Session 4
PPTX
Basic syntax : Algorithm,Flow chart
PPT
Program logic and design
PPT
Introduction to Programming
PPTX
C programming
PPT
Problem Solving Techniques
PPTX
classVIII_Coding_Teacher_Presentation.pptx
PDF
classVIII_Coding_Book018979929470479.pdf
PPT
Computer Programming Computer Programming
PDF
C progrmming
PDF
6272 cnote
PPSX
Algorithms, Structure Charts, Corrective and adaptive.ppsx
PPTX
Computer science principals in terms of Programming
PPTX
COMPUTING AND PROGRAMMING FUNDAMENTAL.pptx
PPTX
COMPUTING AND PROGRAMMING FUNDAMENTAL.pptx
Introduction To Programming
Programming Fundamentals - Lecture 1.ppt
Introduction to Coding
Software fundamentals
Tutor Py
Developing a Coding Program for Users - SWFLN Makerpalooza - Session 4
Basic syntax : Algorithm,Flow chart
Program logic and design
Introduction to Programming
C programming
Problem Solving Techniques
classVIII_Coding_Teacher_Presentation.pptx
classVIII_Coding_Book018979929470479.pdf
Computer Programming Computer Programming
C progrmming
6272 cnote
Algorithms, Structure Charts, Corrective and adaptive.ppsx
Computer science principals in terms of Programming
COMPUTING AND PROGRAMMING FUNDAMENTAL.pptx
COMPUTING AND PROGRAMMING FUNDAMENTAL.pptx

More from SiliconExpert Technologies (13)

PDF
Joining Osum Community And ..
PDF
Sfd Post Event Report
PDF
PDF
Fedora Fs Menoufiya Release 10
PPT
Database Session
PPTX
Eclipse Vs Netbeans
PPT
Introduction to Programming
PPT
How To Write A Cv That Talks For You
PPT
Web Fundamentals
PPT
ugmented Reality BY Dr.Hatem Mohammed
Joining Osum Community And ..
Sfd Post Event Report
Fedora Fs Menoufiya Release 10
Database Session
Eclipse Vs Netbeans
Introduction to Programming
How To Write A Cv That Talks For You
Web Fundamentals
ugmented Reality BY Dr.Hatem Mohammed

Recently uploaded (20)

PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Computing-Curriculum for Schools in Ghana
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
Complications of Minimal Access Surgery at WLH
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Lesson notes of climatology university.
PPTX
Cell Structure & Organelles in detailed.
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Basic Mud Logging Guide for educational purpose
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Classroom Observation Tools for Teachers
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Pre independence Education in Inndia.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PPTX
master seminar digital applications in india
Renaissance Architecture: A Journey from Faith to Humanism
Computing-Curriculum for Schools in Ghana
Microbial disease of the cardiovascular and lymphatic systems
Complications of Minimal Access Surgery at WLH
PPH.pptx obstetrics and gynecology in nursing
Anesthesia in Laparoscopic Surgery in India
Lesson notes of climatology university.
Cell Structure & Organelles in detailed.
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Basic Mud Logging Guide for educational purpose
STATICS OF THE RIGID BODIES Hibbelers.pdf
O5-L3 Freight Transport Ops (International) V1.pdf
Classroom Observation Tools for Teachers
Final Presentation General Medicine 03-08-2024.pptx
Pre independence Education in Inndia.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
master seminar digital applications in india

Introduction To Programming (2009 2010)

  • 1. Introduction to Programming “How to win friends and influence computers”
  • 4. A Brief History of Computers General purpose minions Orders Human calculators Mechanical calculators Electronic calculators General purpose machines Programs
  • 5. What Is Programming Programming is just telling a computer to do something, BUT Computers know very little and have no common sense what-so-ever, so your instructions have to be broken down to small, simple parts, AND Computers will do exactly what you tell them.
  • 7. Basic Programming Programming at it’s core is about two things: defining problems, and solving problems. These two aspects are tightly integrated • To solve a problem you first must clearly know what it is • Clearly and completely defining a problem gets you a long ways towards a solution
  • 9. Four Tools To Get Started Just getting started is often the hardest part of the project. Before diving in to the code, do the design document. Four tools to help are –Action/Event List –Flow Chart –Data Model –Iterative Refinement
  • 10. Action List This is a good tool to use in applications that have user interaction. Write down each action the user can take. Add a bit of detail info to each action • Circumstances in which the user may take the action (1-3 sentences, and/or list) • What happens when they do the action (1-3 sentences) • What other actions this one allows and denies (list format)
  • 11. Flow Charts Flow charts are a very useful tool to clarify and define programming problems • They delineate key points in your program • They’re especially good for state-based programs, such as web applications Don’t get too bogged down in details when creating a flow chart – stay high level
  • 12. Data Model A data model is a detailed description of the information that the application will manipulate. Start with a general idea/concept, then break it down into smaller parts, and repeat. Aim for having each part be a string, a number, or a list or collection thereof.
  • 13. Iterative Refinement - the Ur-Program The process of iterative refinement 2. Say what you want the computer to do 3. If it’s all in terms the computer will understand, then stop, you’re done 4. Otherwise, break each part into simpler steps 5. Go to step 2 NOTE: works for small children as well as computers
  • 14. The Real World These are important concepts, and when done right you end up documenting your code as you go. HOWEVER… Real-world programming often doesn’t explicitly involve these techniques except at high levels in the design document. You should definitely use them there, and for actual coding keep them in mind as fallback strategies if your stuck on a problem.
  • 16. What Computers Can Do Well Doing the same things over and over Remembering things Mathematics, ‘regular’ and true / false Changing actions based on conditions Taking in information Sending out information
  • 17. What Computers Can Do Well Doing the same things over and and Subroutines Loops over Remembering things Variables and Assignment Mathematics, ‘regular’ and true / falseOperators Statements Changing actions based on conditions Conditionals and Blocks Taking in information Sending out information Input Output
  • 18. Statements, and Blocks A statement is a basic instruction for the computer Statements are executed in order, from first to last One or more statements may be grouped together into a block A block is marked by curly braces { and }
  • 19. Loops A loop is a special kind of statement that tells a computer to repeat a given set of instructions A for-loop repeats a given number of times e.g. say “hi” five times: for (1..5) { say “hi” } A while-loop repeats as long as a certain condition is true e.g. go somewhere : while (not arrived) { take step }
  • 20. Subroutines A subroutine, function or procedure is a block of statements that’s been given a name and which is executed when ever that name is used. Essentially, it’s a miniature sub-program that you can use in your larger program. Once a function finishes, the execution returns to the place from which it was called. Functions can take parameters, or arguments, which allow values to be sent into the block of code Functions can return values.
  • 21. Variables A variable has a name, or identifier, and may have a value associated. Associate a given value with a given variable by making an assignment. Variables can be declared, which creates them without any value. Some languages require this.
  • 22. Variable Names MUST: Start with a letter Contain letters or numbers or underscores SHOULD: Be meaningful (often 10+ characters) Be readable (use _ or mixCase to mark words) Follow convention (start lower case, i, x, y)
  • 23. Basic Values Literal values: Numbers 0, -3, 8.223419783 Strings (a series of characters) “zero”, ”0”, “cheddar cheese” Expressions: One or more values, expressions, or variables combined by operators 8.3 * 4.291 2 “smoked” . “ “ . “cheddar” A variable used in a expression is replaced by its value ingredient_count + 3
  • 24. Operators There are all the standard math operators + - * / % () The string concatenation operator combines two or more strings into one Depends on the language (often . or +) There are many other operators too Boolean math Comparisons Specialized Operators combine values and expressions into larger expressions
  • 25. Conditionals A conditional, or branch, statement executes a block of other statements based on whether a given condition is true or false Conditions are evaluated using boolean operators, as well as comparisons and other things that are true or false
  • 26. General Conditional Statement if (condition) Block executed if condition is true else if (other condition) Block executed if other condition is true else Block executed if all conditions are false
  • 27. Input and Output Special statements get data into and out of a program. Details vary by language Data can come from: keyboard, web page, mouse, file, other Data can go to: screen, file, the internet, other
  • 28. Comments Comments are a way to put text in the program code which does not get executed. This is very useful for leaving notes / descriptions / explanations, and for testing. Comments are usually denoted by # or // to comment to the end of the line /* to comment out multiple lines */
  • 29. Best Practices Always make backups of original working code before messing with it Use comments to mark what you change, how, and when, and to keep copies of original statements Test early, test often Work together – more eyes means fewer bugs Read the manual – there are great references online Look at examples