KEMBAR78
CPP01 - Introduction to C++ | PPTX
Software
Development
Michael Heron
Introduction
• Welcome to the module!
• I hope you enjoy it.
• In this module we are going to be talking about how to build
programs using the C++ programming language.
• This serves as preparatory work for you moving onto more
advanced coding next semester.
• Programming is a lot of fun (honest), but it’s also a difficult
topic to learn.
• It’s really important that you stick with it!
Introduction
• Programming is about more than just learning some technical
skills.
• There’s a state of mind that goes with it as well.
• Part of the fun of programming lies in looking at it like a kind
of logical puzzle.
• It’s on this basis that many people code recreationally.
• Mostly, programming is about pattern recognition.
• This is an extremely transferable skill.
Structure of the Module
• There are three lectures for this module every week:
TIMES
• There is also a two hour lab every week.
TIMES
Structure of the Module
• In the first two lectures, we’ll talk about programming topics.
• In the third, we’ll do some collaborative class-work .
• Programming is often best done away from a computer.
• In the lab, we’ll alternate between courseworks and class
exercises.
Structure of the Module
• The module has three sets of assignments.
• The first is a portfolio of projects developed through the
weeks.
• Four small programs.
• This counts for 20% of your grade.
• The second is a larger project that you decide upon yourself.
• With guidance/approval from me
• This counts for 20% of your grade
• The third part is an exam.
• This counts for 60% of your grade
Programming
• Programming is one of the most unique things anyone ever
learns to do.
• I have never encountered anything quite like programming in
terms of the blend of skills it requires.
• Fundamentally, it is about compensating for one simple fact.
• Computers are soul-crushingly stupid, and they need people to
tell them what to do.
Class Exercise
• So, let’s see what writing a program works like in the abstract.
• Get into groups of two or three.
• Decide on a simple(ish) shape to draw.
• Not a simple geometric shape, but nothing especially
complicated.
• Then, write out the instructions for drawing that shape as
precisely as you can.
• For someone who doesn’t know what your shape is supposed to
be.
• After a few minutes, I’ll draw your shapes on the board from
the instructions you give me.
A Computer Program
• A computer program breaks down into a series of very small,
very specific instructions to the computer.
• These have to be in the computer’s own language.
• A series of low level, primitive grunts and whistles.
• 1s, 0s, and the ability to perform trivial operations on those
numbers.
• In the Olden Days, this is how people wrote computer code.
• In machine code
Modern Programming
• Over the years, we have increasingly abstracted away from
this idea.
• We now use what are known as high level languages.
• High level indicates how far we are abstracted from the underlying
1s and 0s
• Most programming languages are now designed to be human
readable.
• Well…
Modern Programming
• C++ is an example of a high level language.
• It frees us up to think about programs in terms of the flow of logic
rather than on the ‘administrative’ work.
• We write in a vaguely human readable language.
• Special software tools then turn this human readable
language into something the computer can understand.
Compilation
• The process of turning our human readable code into
something the computer understands is called compilation.
• It’s kind of a translation process.
• In order for compilation to be possible, programming
languages have to be very strict.
• Computers cannot deal with ambiguity.
• The exact rules we must obey when giving instructions to the
computer is known as the language syntax.
Compilation
• Where there is ambiguity, or when things have not been
expressed precisely enough for the compiler, it issues what are
called syntax errors.
• Essentially the compiler says ‘Woah, I don’t even know how to
turn that into something the computer understands!’
• These must be fixed before a program can be compiled at all.
• C++ complicates it by making the error messages horribly
unhelpful, but we’ll talk about these as we go along.
The Implications
• The implications of all of this is that it’s really important to
follow instructions that you are given – not just to the letter,
but down to the punctuation
• Punctuation symbols in computer languages are used to express
special meaning.
• This will come easier with practice.
• The rules aren’t complicated, they are just necessarily fiddly.
After Compilation
• Once your program has no more syntax errors (in technical
terms, it compiles), the program is then executed (or run).
• Here is where the next level of problems occur.
• When a program loads, but doesn’t do what it’s supposed to
do, it is said to have logic errors.
• The problem is in what code has been written, not how the code
has been written.
A Note of Advice
• Please do not look on errors as a bad thing.
• They’re really, really not at this stage.
• You will learn more from getting errors and fixing them than
you will from getting everything right the first time.
• Nobody gets everything right the first time.
• It’s easy to get discouraged, but you have to think of each
error you solve as a little mini-lesson in programming.
• As long as you know why it happened, and how to avoid it
happening in the future, you just became a better programmer.
Writing a C++ Program
• In the labs, we are going to be using a piece of software called
Visual Studio .NET.
• It’s tremendously powerful, and as such not the easiest thing in
the world to use.
• This is a package of software known as an Integrated
Development Environment (IDE).
• You use your IDE to create the programs that the computer
will run.
What We Study
• This module is not just about writing programs.
• You can feel free to disbelieve that, since we’ll be doing that a lot.
• It’s about building the skills and mindset needed to be able to
write programs properly.
• It’s about:
• Designing
• Coding
• Debugging
• Testing
• Documentation
What We Study
• You are not going to learn how to do any of this in these
lectures.
• All these lectures can do is point you in the right direction.
• The only way you learn about programming is by practicing it.
• It’s an active, doing skill. It’s not something you know, it’s
something you do.
Practice
• The lectures will introduce new syntax, new tools, and new
techniques.
• The assessments will make sure you can use them.
• In between those two, you have to practice.
• Just write programs. Play about with programs you are given.
• Experiment with your programs.
• Make a copy of code that works, and then just change things
around to see what happens.
• ‘Well, do that and see what happens’ is something you’ll hear me
say a lot.
Learning to Program
• Programming is a skill built cumulatively.
• If you fall behind, you’ll need to make the effort to catch up.
• You can’t miss any of the material and still progress.
• If you are having problems, the absolutely wrong way to deal
with them is to skip classes.
• That just makes the problem worse.
• Even if you find it difficult to begin with, there’s no reason to
believe you always will.
• There’s a point, and it’s a different point for everyone, where it all
just clicks.
Programming is Fun
• It really is, and that doesn’t get said enough.
• Writing a program is like solving a crossword, or a Sudoku
puzzle.
• Because it’s a pattern solving exercise, there are also many
ways in which you can get better at programming.
• Many programmers are also good chess players for example,
because both are creative ,pattern solving exercises.
Summary
• Welcome to your module!
• Programming is challenging, but very rewarding.
• It’s also a skill very few people have.
• We’ll be writing C++ programs.
• We write them
• We debug them
• We execute them
• Most of this is down to you.
• I’m here to help, but I can’t really teach you how to do any of
this!

CPP01 - Introduction to C++

  • 1.
  • 2.
    Introduction • Welcome tothe module! • I hope you enjoy it. • In this module we are going to be talking about how to build programs using the C++ programming language. • This serves as preparatory work for you moving onto more advanced coding next semester. • Programming is a lot of fun (honest), but it’s also a difficult topic to learn. • It’s really important that you stick with it!
  • 3.
    Introduction • Programming isabout more than just learning some technical skills. • There’s a state of mind that goes with it as well. • Part of the fun of programming lies in looking at it like a kind of logical puzzle. • It’s on this basis that many people code recreationally. • Mostly, programming is about pattern recognition. • This is an extremely transferable skill.
  • 4.
    Structure of theModule • There are three lectures for this module every week: TIMES • There is also a two hour lab every week. TIMES
  • 5.
    Structure of theModule • In the first two lectures, we’ll talk about programming topics. • In the third, we’ll do some collaborative class-work . • Programming is often best done away from a computer. • In the lab, we’ll alternate between courseworks and class exercises.
  • 6.
    Structure of theModule • The module has three sets of assignments. • The first is a portfolio of projects developed through the weeks. • Four small programs. • This counts for 20% of your grade. • The second is a larger project that you decide upon yourself. • With guidance/approval from me • This counts for 20% of your grade • The third part is an exam. • This counts for 60% of your grade
  • 7.
    Programming • Programming isone of the most unique things anyone ever learns to do. • I have never encountered anything quite like programming in terms of the blend of skills it requires. • Fundamentally, it is about compensating for one simple fact. • Computers are soul-crushingly stupid, and they need people to tell them what to do.
  • 8.
    Class Exercise • So,let’s see what writing a program works like in the abstract. • Get into groups of two or three. • Decide on a simple(ish) shape to draw. • Not a simple geometric shape, but nothing especially complicated. • Then, write out the instructions for drawing that shape as precisely as you can. • For someone who doesn’t know what your shape is supposed to be. • After a few minutes, I’ll draw your shapes on the board from the instructions you give me.
  • 9.
    A Computer Program •A computer program breaks down into a series of very small, very specific instructions to the computer. • These have to be in the computer’s own language. • A series of low level, primitive grunts and whistles. • 1s, 0s, and the ability to perform trivial operations on those numbers. • In the Olden Days, this is how people wrote computer code. • In machine code
  • 10.
    Modern Programming • Overthe years, we have increasingly abstracted away from this idea. • We now use what are known as high level languages. • High level indicates how far we are abstracted from the underlying 1s and 0s • Most programming languages are now designed to be human readable. • Well…
  • 11.
    Modern Programming • C++is an example of a high level language. • It frees us up to think about programs in terms of the flow of logic rather than on the ‘administrative’ work. • We write in a vaguely human readable language. • Special software tools then turn this human readable language into something the computer can understand.
  • 12.
    Compilation • The processof turning our human readable code into something the computer understands is called compilation. • It’s kind of a translation process. • In order for compilation to be possible, programming languages have to be very strict. • Computers cannot deal with ambiguity. • The exact rules we must obey when giving instructions to the computer is known as the language syntax.
  • 13.
    Compilation • Where thereis ambiguity, or when things have not been expressed precisely enough for the compiler, it issues what are called syntax errors. • Essentially the compiler says ‘Woah, I don’t even know how to turn that into something the computer understands!’ • These must be fixed before a program can be compiled at all. • C++ complicates it by making the error messages horribly unhelpful, but we’ll talk about these as we go along.
  • 14.
    The Implications • Theimplications of all of this is that it’s really important to follow instructions that you are given – not just to the letter, but down to the punctuation • Punctuation symbols in computer languages are used to express special meaning. • This will come easier with practice. • The rules aren’t complicated, they are just necessarily fiddly.
  • 15.
    After Compilation • Onceyour program has no more syntax errors (in technical terms, it compiles), the program is then executed (or run). • Here is where the next level of problems occur. • When a program loads, but doesn’t do what it’s supposed to do, it is said to have logic errors. • The problem is in what code has been written, not how the code has been written.
  • 16.
    A Note ofAdvice • Please do not look on errors as a bad thing. • They’re really, really not at this stage. • You will learn more from getting errors and fixing them than you will from getting everything right the first time. • Nobody gets everything right the first time. • It’s easy to get discouraged, but you have to think of each error you solve as a little mini-lesson in programming. • As long as you know why it happened, and how to avoid it happening in the future, you just became a better programmer.
  • 17.
    Writing a C++Program • In the labs, we are going to be using a piece of software called Visual Studio .NET. • It’s tremendously powerful, and as such not the easiest thing in the world to use. • This is a package of software known as an Integrated Development Environment (IDE). • You use your IDE to create the programs that the computer will run.
  • 18.
    What We Study •This module is not just about writing programs. • You can feel free to disbelieve that, since we’ll be doing that a lot. • It’s about building the skills and mindset needed to be able to write programs properly. • It’s about: • Designing • Coding • Debugging • Testing • Documentation
  • 19.
    What We Study •You are not going to learn how to do any of this in these lectures. • All these lectures can do is point you in the right direction. • The only way you learn about programming is by practicing it. • It’s an active, doing skill. It’s not something you know, it’s something you do.
  • 20.
    Practice • The lectureswill introduce new syntax, new tools, and new techniques. • The assessments will make sure you can use them. • In between those two, you have to practice. • Just write programs. Play about with programs you are given. • Experiment with your programs. • Make a copy of code that works, and then just change things around to see what happens. • ‘Well, do that and see what happens’ is something you’ll hear me say a lot.
  • 21.
    Learning to Program •Programming is a skill built cumulatively. • If you fall behind, you’ll need to make the effort to catch up. • You can’t miss any of the material and still progress. • If you are having problems, the absolutely wrong way to deal with them is to skip classes. • That just makes the problem worse. • Even if you find it difficult to begin with, there’s no reason to believe you always will. • There’s a point, and it’s a different point for everyone, where it all just clicks.
  • 22.
    Programming is Fun •It really is, and that doesn’t get said enough. • Writing a program is like solving a crossword, or a Sudoku puzzle. • Because it’s a pattern solving exercise, there are also many ways in which you can get better at programming. • Many programmers are also good chess players for example, because both are creative ,pattern solving exercises.
  • 23.
    Summary • Welcome toyour module! • Programming is challenging, but very rewarding. • It’s also a skill very few people have. • We’ll be writing C++ programs. • We write them • We debug them • We execute them • Most of this is down to you. • I’m here to help, but I can’t really teach you how to do any of this!