Upload
posy-beasley
View
217
Download
2
Embed Size (px)
Citation preview
Queensland University of TechnologyCRICOS No. 00213J
1
ITB001Problem Solving and Programming
Lecture 1
Faculty of Information Technology
Queensland University of Technology
CRICOS No. 00213J
a university for the worldrealR 2
Meet the staff
• Dr. Glenn Smith
• Coordinator• Margaret Street office
• Prof. Colin Fidge
• Lecturer• S Block office
CRICOS No. 00213J
a university for the worldrealR 3
Format
• Contact time:– 1 x 1-hour lecture each week– 1 x 2-hour workshop each week– ‘Drop in’ practical sessions each week
• Preparation:– Must read lecture notes and listen to pre-recorded
topics before attending lecture
CRICOS No. 00213J
a university for the worldrealR 4
Assessment
• A major assignment, in three parts (50% Total)• Written examination (50%)
CRICOS No. 00213J
a university for the worldrealR 5
Software
• In this unit we use a software package called DrScheme• DrScheme is available in the computer laboratories• You may download your own copy of DrScheme from http://www.drscheme.org/
CRICOS No. 00213J
a university for the worldrealR 6
Reference material
• DrScheme has a built-in ‘help desk’ with lots of information
• Relevant textbooks:– Concrete Abstractions: An Introduction to Computer
Science Using Scheme, by M. Hailperin, B. Kaiser and K. Knight•http://www.gustavus.edu/+max/concrete-abstractions.html
– Structure and Interpretation of Computer Programs, by H. Abelson and G. Sussman with J. Sussman•http://mitpress.mit.edu/sicp/
CRICOS No. 00213J
a university for the worldrealR 7
Reference material
– The Schematics of Computation by V. Manis and J. Little (Prentice-Hall, 1995)
– How to Design Programs: An Introduction to Programming and Computing, by M. Felleisen, R. Findler, M. Flatt and S. Krishnamurthi (MIT Press 2002)
• The first two textbooks listed above are available at the QUT bookshop, as well as online
CRICOS No. 00213J
a university for the worldrealR 8
More information
• Lecture notes, assignment sheets, exercise solutions, etc, will be available from the ITB001 web site– Check this web site regularly– Read the Course Unit Outline and the Week One Unit
Information
CRICOS No. 00213J
a university for the worldrealR 9
What is this unit about?
• Problem solving skills and strategies used in software development– Decomposing big problems into manageable parts– Using abstraction to make solutions readable and
maintainable• An understanding of fundamental programming skills
– Generic coding techniques applicable to a wide range of programming and scripting languages
– Familiarity with the factors that affect the performance of computer programs
CRICOS No. 00213J
a university for the worldrealR 10
Teaching format
1. Each week’s lecture will introduce a programming concept that can be used to solve particular computational problems
2. In the workshops you will then have an opportunity to use this concept to solve several example problems, with help from your classmates and tutors
3. Finally, the practical sessions will give you an opportunity to check your solutions on the computer (or you can use your own computer)
CRICOS No. 00213J
a university for the worldrealR 11
Brush up on your maths
• In exercises and the assignment we will assume knowledge of some mathematical concepts such as rational numbers, modulo arithmetic, Boolean logic, etc
• We won’t have time to go through these topics in detail during lectures, so you will need to revise some of them yourselves as homework
CRICOS No. 00213J
a university for the worldrealR 12
Aims of today’s lecture
• Introduce different approaches to problem solving• Identify the relationship between problem solving and
programming• Explain the role of computer programming in developing
software systems• Introduce a sequence of steps used to develop a
computer program• Introduce some of the terms and concepts used in
computer programming
Queensland University of TechnologyCRICOS No. 00213J
13
Problem Solving and Programming
CRICOS No. 00213J
a university for the worldrealR 14
Problem solving strategies
• Trial and error– In trial and error, we try an option to see if it works– If it works, then we have a solution– If it doesn’t work—or there is an error—then we try
another option • Brainstorming
– An organized approach for producing ideas by letting the mind think without interruption
CRICOS No. 00213J
a university for the worldrealR 15
Problem solving strategies
• Lateral thinking– A technique of problem solving by approaching
problems indirectly at diverse angles instead of concentrating on one approach at length
• Divide and conquer– A strategy particularly related to programming– Identify sub-parts of the problem that are easier to
solve, then recombine individual solutions to produce an overall solution
CRICOS No. 00213J
a university for the worldrealR 16
Problem solving strategies
• Decrease and conquer– A variation on divide and conquer where the problem
itself cannot be decomposed– Decrease the size of the set of values involved,
typically by one, and repeat this process until the solution is trivial
CRICOS No. 00213J
a university for the worldrealR 17
Problem solving strategies
• Other useful strategies:– Clarify the problem– Identify key elements– Draw a diagram– Consider a specific
example– Refer to literature
– Consider related problems
– Consider an extreme case
– Discuss with peers
http://www.une.edu.au/psychology/staff/malouff/problem.htm
CRICOS No. 00213J
a university for the worldrealR 18
Programming
• What is programming?– Computer programming (often simply
programming) is the craft of implementing one or more interrelated abstract algorithms using a particular programming language to produce a concrete computer program. Programming has elements of art, science, mathematics, and engineering.
[Wikipedia]
CRICOS No. 00213J
a university for the worldrealR 19
Problem solving and programming
• Programming is our tool for realising a particular solution• But we must “solve” the problem first, then design and
build the solution– However, the design must be compatible with the
tools used– Hence we must first understand how to use the tools
CRICOS No. 00213J
a university for the worldrealR 20
Problem solving and programming
• Problem: Your dog gets wet when it rains
• Solution: A dog house• Design: An enclosed
structure of wood and nails
• Implementation: Needs carpentry skills
CRICOS No. 00213J
a university for the worldrealR 21
Problem solving and programming
• In programming this means we need to understand:– The programming language used to express our
solutions (the toolkit)– An appropriate programming strategy (how to
assemble the parts)– The computational processes produced by our
programs (properties of the finished program)
Queensland University of TechnologyCRICOS No. 00213J
22
Software Engineering: The Big Picture
CRICOS No. 00213J
a university for the worldrealR 23
Software engineering
• Software engineering is the discipline of solving a computational problem by building a software system
• Programming is only one part of software engineering• Implementation of large projects can take many years,
involve many people, and cost millions of dollars• Successful completion of large projects requires:
– Project planning and management – Team work – Communication skills– Technical knowledge and skills
CRICOS No. 00213J
a university for the worldrealR 24
Small-scale programming
• In this unit we will solve small problems and write small programs– We must do this first to develop and practice our
problem solving and programming skills– Other units look at large-scale problem solving
• We must develop a basic knowledge of programming before we can be part of a software engineering team– In the same way a doctor must first learn anatomy
before undertaking clinical diagnosis
CRICOS No. 00213J
a university for the worldrealR 25
Significance
• Even if you are not a software engineer, all I.T. professionals should understand the programming process:– To communicate effectively with other I.T.
professionals– To appreciate what is practical in the development of
computer programs
Queensland University of TechnologyCRICOS No. 00213J
26
The Programming Process
CRICOS No. 00213J
a university for the worldrealR 27
Programming processes
• When solving large problems, we must follow a well-defined process to achieve repeatable success
• The process that we will follow in this unit focuses on the problem solving and programming part of the larger software engineering process
• We will apply this process to small problems so that we are confident and competent in the process when we need to work on larger problems
CRICOS No. 00213J
a university for the worldrealR 28
The traditional ‘waterfall’programming process
Analyse
Design
Implement
Test
CRICOS No. 00213J
a university for the worldrealR 29
Steps in the programming process
1. Analysis– What information is important?– Is further information or knowledge required?– What values are given as inputs?– What values are required as outputs?– Identify test cases and their answers (otherwise,
how would we know when we’ve finished?)– Identify sub-tasks– Consider initial strategies for solving this problem
CRICOS No. 00213J
a university for the worldrealR 30
Steps in the programming process
2. Design– Develop the overall solution– Identify useful programming constructs– Identify existing code that may be reused directly or
can provide a model for the required code– May need to go back and further analyse the
problem
CRICOS No. 00213J
a university for the worldrealR 31
Steps in the programming process
3. Implement– Translate the design into program code– Start with smaller pieces of the design– Write simplified code first, then test it, then extend it
• Do not need to get the complete answer in one step
– Use a checklist to track any possible problems– Combine smaller pieces to produce the complete
solution
CRICOS No. 00213J
a university for the worldrealR 32
Steps in the programming process
4. Test– Check that the program works correctly– Compare actual outputs with pre-calculated values
or predicted behaviour• Just because it looks right doesn’t mean it is right
– Consider what values might ‘break’ your program• e.g., zero values, empty lists, out-of-range
values, values of the wrong type, repeated values, etc
CRICOS No. 00213J
a university for the worldrealR 33
Computer programming concepts
• Programming involves many new concepts• What is a computer program?
– An unambiguous set of instructions that tells a computer how to behave in response to given inputs
• How does a program run?– We need to ‘compile’ or ‘interpret’ programs from
human-readable form into machine-executable code– Each of the resulting instructions is evaluated
individually, in sequence
CRICOS No. 00213J
a university for the worldrealR 34
Computer programming concepts
• What does a program contain?– Identifiers (names)– Variables (named values)– Expressions (something that can be evaluated)– Control constructs (directives to the computer)– Procedures (a named expression that can be reused)
• What are the common tasks involved?– Coding (writing the computer program)– Testing (testing for errors in a program)– Debugging (removing errors, or bugs, from programs)
CRICOS No. 00213J
a university for the worldrealR 35
What is Scheme?
• Scheme is a ‘functional’ programming language often used for solving problems requiring a lot of searching
• We use it as a teaching language because it is simple yet powerful– The DrScheme programming environment allows us
to develop and execute programs quickly and easily• The principles we will illustrate using Scheme transfer
readily to other programming languages (such as Java and C#) and scripting languages (such as Perl and Python)
CRICOS No. 00213J
a university for the worldrealR 36
Homework
• Before next week’s workshop, you must complete the worksheet provided on the ITB001 web site
• If you have any difficulties, please discuss with workshop tutors and lab facilitators in week 2
• Ensure that you have allocated yourself to a workshop session