COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates...

67
COMP 202 – Introduction to Computing 1 COMP-202 Unit 0: Course Details CONTENTS: Focus of the Course and Prerequisites Outline and Textbook Course Structure and Grading Scheme Computer Lab Info and Required Software Course Communication

Transcript of COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates...

Page 1: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP-202Unit 0: Course Details

CONTENTS:Focus of the Course and PrerequisitesOutline and TextbookCourse Structure and Grading SchemeComputer Lab Info and Required SoftwareCourse Communication

Page 2: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP-202Intro to Computing I

WELCOME!

Page 3: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP-202 - Course Details 3

Reasons for being here?

–Reason #1:• This is a required course for my program–Reason #2:• Learning computer programming is a funelective.–Reason #3:• It's a required course and learning  computer programming is fun.–Reason #4:• sit in the wrong class?

Page 4: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP-202 - Course Details 4

Focus of the Course•Introduction to computer programming–Basics of problem solving–Essentials of program design and implementation

•Coursework will be done in a programming language called Java–Concepts taught in the course apply to other programming languages as well

•Aimed at students with little or no background in programming and/or knowledge of computer science

Page 5: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 5

Goals of this course (What you will be able to do in a few months)

•Understanding how computers think•Being able to describe a task in a way a computer can understand•Breaking complex tasks into smaller, simpler tasks•Translating these instructions into the programming language of Java•Pass this course•Have fun

Page 6: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

Page 7: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 7

I have heard this course is super hard!

• Indeed, programming computers is a very time consuming and sometimes difficult process.

• Many challenges ahead– Be prepared

• You need to spend a significant amount of quality time on this course

• We will try to do everything to make the course less stressful

Page 8: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 8

I hate computers and am only here because my stupid faculty made me take this @#$# course!

•Even if you never write another program, this course will help you to:

–Understand what types of problems computers can and can't solve in practice.–Improve your logical thinking and problem solving skills–A new tool to help you with your other courses.

Page 9: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 9

Course Plan•We will spend about 4 weeks learning the “basics” of programming. This will involve mostly learning about the FLOW of a program•Next, we will spend about 3 weeks introducing the concept of “Object Oriented Programming”•Finally, we will spend the last 5 weeks going into more detail with applications and examples of Object Oriented Programming

Page 10: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP-202 - Course Details 10

Prerequisites•Prerequisite: A CEGEP-level math course or equivalent•For those who graduated from high school outside Quebec and thus never attended CEGEP: any upper-level math course•In any case, the ability to think logically and rigorously is more important than calculus, algebra or trigonometry

Page 11: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP-202 - Course Details 11

Non-Focus of the Course•This course is not about:–How to use, set-up, or configure a computer–How to surf the Web or send e-mail–How to chat with friends using the Internet–How / where to download music and movies from the Internet–How to write essays with a word processor–How to make presentations with presentation software–How to design Web pages–How to repair your computer if it breaks down

•Instruction will be provided on how to use the software packages necessary to complete coursework

Page 12: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 12

How do I Ace this course?

–Practice! When you see an example in class, try it at home.–Do your assignments!!!!!!!–Do your assignments!!!!!!!–Prepare for the lectures ahead of time. Make sure you understand the previous lecture and come prepared to class with questions.–Ask a question whenever you don't understand something.

• It's the best way for the instructors to know we are not explaining something clearly.

• In most classes, the lectures will be designed to take up less than the full amount of time to leave room for questions.

Page 13: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

13

•A bit about your instructor (Xue)• Education

– BS, Mathematics, 1996Tsinghua University

– MS, Automation, 1999Tsinghua University

– PhD, Computer Science, 2006University of Illinois at Urbana-Champaign (UIUC)

Page 14: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

14

•A bit about your instructor (Xue)• Work experience

– Visiting Researcher (on leave from McGill), 2006-2007HP Labs, Palo Alto, USA

– Assistant Professor, 2007 - 2009McGill University, Montreal, Canada

– Samuel R. Thompson Associate Professor, 2010-2011University of Nebraska LincolnLincoln, NE, USA

– Associate Professor, 2011 - presentMcGill University,Montreal, Canada

Page 15: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

15

•A bit about your instructor (Xue)• Research Interests

– Real-Time and Embedded Systems– Cyber-Physical Systems and Wireless Sensor

Networks– Data Centers and Cloud Computing– Communication and Wireless Networks– Internet Technologies and Green Computing

• More info:– Google “Xue Liu”– Or go directly at:

• www.mcgill.ca/~xueliu

Page 16: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP 202 - Introduction 16

Coordinates and Office Hours

•McConnell Eng. Building, Room 326•Office Hours:–Thursdays: 11:25 AM - 12:25 PM–Or by appointment through email–Please pay attention to the email format info (to follow)

Page 17: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 17

Course Communication•Course home page:

• http://www.cs.mcgill.ca/~cs202

–Instructor contact information, course outline, lecture notes, assignment specifications, and other course material

•myCourses (WebCT Vista):–http://www.mcgill.ca/mycourses

–Discussions, announcements, assignment submission and grading, marks–You are responsible for making sure that your marks are correct, and reporting errors to your instructor

Page 18: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 18

Discussion Boards

• When you have a general question about the assignments or course material, you should post it to WebCT. This way other students can share your knowledge. Instructors and TAs will regularly monitor the discussion board.

• When you have involved coding questions, you can also go to either the TA office hours or the instructors' as they'll be able to give you a better answer in person.

• It is OK to post small coding snippets to demonstrate a point, but it is NOT okay to post your entire assignment.

Page 19: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 19

Email• I will try my best to answer your email within 48 hours.• Due to the large amount of emails, please make sure to put

“COMP-202:’’ as the beginning of the subject line of your email to avoid possible delays.

• When you have an administrative question (e.g You can't attend the midterm, you don't feel the grading was fair on an assignment, etc) that will require keeping track of, make sure to put in front of your subject line (after “COMP-202:” )

• ASSIGNMENTn (where n is the assignment, i.e. ASSIGNMENT1, ASSIGNMENT2, etc.)

• MIDTERM• FINAL• …

• This will help assure your email isn't forgotten about

Page 20: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 20

Course Structure: Lectures•Lectures (3 hours/week, “compulsory”)–Highlight key concepts; opportunity to practice and ask questions, receive and give feedback–You will get more out of the class if you do the readings before hand and participate.–All material taught in lectures is examinable unless otherwise stated

–Ask Questions if you don't understand something.

–It is the only way I'll know whether I'm explaining something clearly or not.

Page 21: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 21

Assignments

• Assignments are designed to let you practice the things you learn in class.

• It is VERY important that you do the assignments by yourself, as they offer you a chance to get feedback on your progress.

Page 22: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 22

Midterm

• March 5th in the evening (from 18:00 until 21:00).• Exam will be held in Leacock 132 and Adams

Auditorium.• Exact room will be announced later.

Page 23: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 23

Outside of class•Tutorials (optional but very useful)

• There will be several tutorials throughout the term. These will be designed to correspond with the assignments as well as the midterm and final

• Will be led by a teaching assistant• Smaller groups typically

•Office hours (2 instructors, about 8 teaching assistants)

• Many office hours per week• TA office hours start next week; details to

be announced

Page 24: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 24

Grading Scheme (1)•4 assignments: 20%•Assignment 1: 5%•Assignment 2: 5%•Assignment 3: 5%•Assignment 4: 5%•All assignments count toward your final grade•The last assignment will be longer and much more involved than the others.–One of the best ways to learn the material–MUST be done INDIVIDUALLY–Lateness policy: 10% per day up to a maximum of 3 days. It's possible we will alter this for a specific assignment, so it's important to keep tuned to WebCT and the course webpage.

Page 25: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 25

Grading Scheme (2)•4 assignments: 20%•1 midterm examination: 20% (Date/Time TBA ASAP)–To be held outside lecture hours; written exam (no computers)

–E-mail your instructor as soon as possible if you have a conflict!•1 final examination: 60%–Held during final exam session; written exam (no computers)

Page 26: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 26

Grading Scheme (3)•For students who do worse on the midterm than the final exam, the grading scheme will be 20% assignments and 80% final.

•However, it is highly recommended that you pretend you didn't know about this option!

Page 27: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 27

Plagiarism :(

is bad so don't do it!

Please read the rules about academic integrity and plagiarism on course website and McGill University's website.

Page 28: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP-202 - Course Details 28

Plagiarism: Policy•Assignments MUST be done INDIVIDUALLY–Do NOT work in groups–Do NOT copy work someone else did–Do NOT allow anyone to copy your work

•Assignments MUST be ENTIRELY YOUR OWN WORK–Do NOT submit code / programs you did not write yourself

•Countermeasures–Random verifications by TAs during grading–Use of software similarity detection tools to compare assignment submissions–Students might be asked to explain their code to instructors at any time

Page 29: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 29

Recommended Textbook

• How to Think Like a Computer Scientist (Java Edition)

• http://openbookproject.net/thinkcs/java/english/dist_v4.0/thinkapjava.pdf

Page 30: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 30

SOCS Computer Labs•If you are officially registered in the course, you can create an account to use the computers on the 3rd floor of Trottier building•Computer availability:–Computers in open areas: physically accessible 24 hours a day, 7 days a week–Computers in side rooms: physically accessible on weekdays 10:00 - 20:00, weekends 12:00 - 20:00•Consultant on duty: weekdays 10:00 - 20:00, weekends 12:00 -20:00•Computers run GNU/Linux (Unix-like OS), not MS Windows–Unix seminars are offered by SOCS Systems staff

Page 31: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 31

Required Software•You are encouraged to use your personal computer or laptop to complete course work•Software used in this course–Required: Java Development Kit (JDK)–Optional: RText, Eclipse (later in the course)•See course outline for details on how to obtain the above software packages•All programs you submit for assignments must compile and run using JDK 6 or later–JDK is backward compatible; programs that compile and run under previous versions also compile and run under JDK 6–More info can be found on course webpage

Page 32: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details32

Useful Tips•Do read everything carefully: slides, notes, textbooks, instructions, assignment specifications, documentation, announcements on myCourses, ...•Do not wait until the last minute to do your assignments•Do not fall behind; each new concept builds on previous ones•Contact instructors / TAs if you have difficulties•Do NOT expect to be given every single detail; you will have to look things up in the provided material and deduce some things on your own•“Software is hard!”•Experiment•Practice makes perfect!

Page 33: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 33

With that in mind...

• With that in mind, let's get started (sorry!).

Page 34: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 34

Today's plan

• Miller's law and chunking• Solving a problem like a computer

scientist• Your first Java program (time

permitting)

Page 35: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 35

Chunking and George Miller• George Miller devised a law known as Miller's law that

roughly speaking, states humans can keep track of approximately 7 chunks in our head at once.

• The word chunk is fairly vague, but the idea is our brain will break things up into various groupings, and we can keep ~7 in our head at once.

• If we make these groupings in a smart way, we can store lots of information in our head.

• If we don't make the groupings in a smart way, we won't be able to store much.

Page 36: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 36

Example• Let's now do a series of tests to see Miller's law in

play.

• On the next slide, I'll show you a letter. The goal is to remember the letter.

Page 37: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 37

Example

a

Page 38: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 38

How many people were able to remember?

Page 39: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 39

Now?

apq

Page 40: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 40

Now?

rabydzl

Page 41: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 41

Now?

rabydzlmbqruzmlapzssbioavvbz

Page 42: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 42

Now?

McGill UniversityApple Computer

MontrealAirplane

Page 43: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 43

Why is that so much easier?• It's actually a more letters!• But, of course, our brain can organize them in a

way that we are actually able to keep track of everything.

• This is because we have organized our language so that we can view units of size bigger than just 1 letter.

• Here we have organized things into chunks of words

• However, there comes a point where organizing things into chunks of words is too much.

Page 44: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 44

Now?Couch Plate

Laundry Coffee Walk Shirt

Backpack Ziplock Hand Mickey

Page 45: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 45

Now?

ToBeOrNotToBeThat IsTheQuestion

Page 46: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 46

Why is that so much easier?

• Here we see a different level of abstraction. We now think about things on a sentence level.

Page 47: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 47

Programming is the same

• There are only a few commands one can “tell” a computer.

• Computers are basically just a bunch of electrical switches.

• But we organize them in ways that make solving problems manageable.

Page 48: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 48

Programming is the same

• When you do this properly, you never have to think about things on a low level.

• For example, when repeating “to be or not to be” you don't need to think or remember that the first letter is a “t”

• However, when we process a disorganized jumble of letters, you do have to think about that.

Page 49: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 49

Ways we organize commands to a computer.

• 1)Programming languages: We have devised programming languages that organize several instructions at once.

• For example, to add 1 and 1 in Java, you can write 1+1

• 2)Instructions within programming languages:• In addition to what comes with the language, we

can add our OWN abstractions by organizing your program in certain ways.

Page 50: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 50

Ways we organize commands to a computer.

• Most of this course, we will be discussing ways that you can abstract things, so that you don't have to keep track of too many things at once.

Page 51: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 51

Key Abstraction Technique: Splitting a problem into parts

• Suppose you have to get from Vancouver to Montreal. How could you go about doing this?

• There are many things you have to worry about:• 1)What means of transportation will you use?• 2)Where will you stay while you are traveling?• 3)Where is your final destination?• 4)How much will the trip cost?

Page 52: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 52

Key Abstraction Technique: Splitting a problem into parts• Rather than trying to solve all of these at once, it's

best to tackle each problem one at a time.

• 1)What means of transportation will you use?

• Here we have several choices. A good technique for solving a problem, is to think about what the input and output of a problem is.

• What could be the input to this problem? (There are no wrong answers.)

Page 53: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 53

Choosing transportation techniques : input

• How much time you have• How much money you have• How much luggage you have• Whether you own a car• ...

Page 54: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 54

Choosing transportation techniques : output

• The output to this problem is your selection. For example:

• “By car”• “By plane”• “By hitchhiking”• “By plane until Dorval, then Taxi to Montreal”• “By plane until Dorval, then hitchhike to Montreal”

• Let's suppose for the exercise, we choose “by car”

Page 55: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 55

The next step....

• Now that we have chosen to go by car, we want to figure out how we can get from Vancouver to Montreal.

Page 56: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 56

Driving from Vancouver to Montreal

• One way we could think of solving this problem is to break it down into 3 pieces:

• 1)Getting from where you are in BC to a highway

• 2)Getting to the city of Montreal• 3)Getting to your final address in Montreal

Page 57: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 57

Driving from Vancouver to Montreal

• Each of these parts has different constraints in it. One useful observation is that while we are doing each step, we don't need to worry much about what we have to do at the next step (except at the very end of each step)

• For example, while trying to figure out how to get from Alberta to Ontario (part of step 2), you will not be worried whether St. Denis is one way or two ways.

• You know that you can solve that part when you reach Montreal.

• Similarly, when you reach Montreal, you don't care how you got from Alberta to Ontario.

Page 58: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 58

Why is this important?• This is important because our brains tend to get confused

when we have to handle too much information at the same time.

• We are great at solving problems with 4 or 5 constraints in them, but we are bad when it's too much.

Page 59: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 59

Example: Writing an Outline for an Essay

• Why do teachers suggest writing outlines for papers?

• The idea is so you can map out each paragraph or key point and then when you are writing that paragraph, you only have to think about that one point!

Page 60: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 60

Relation to programming:• When we solve problems with a computer, our goal is to

always focus on one specific task at at time.• This task should be as small as possible and we should

generally not be able to split it into further parts.• This way, while we try to solve the task, we can consider

as few things at a time. (This is part of the reason we want to make it a small task)

Page 61: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 61

Java vs. Other programming languages

• We are going to study Java. However, most other languages, (e.g. C, C++, C#, Python, Perl, Matlab, etc.) will work the similar way

• The differences will be:

• 1)What abstractions come with the language.• 2)The exact syntax for writing in the language.

– Syntax refers to the structure of your program and the rules about that structure.

– The computer can only understand the program if it is syntactically correct

Page 62: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 62

A (very) simple Java program

public class HelloWorld {public static void main(String[] args) {

System.out.println("Hello World!");}

}

What do you think this does?

Page 63: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 63

A Quick DemoOpen a text editor and write a quick java programWrite your java code in a file called HelloWorld.javaCases are important!Go to command lineTypejavac HelloWorld.java

This will make a file called HelloWorld.class

To run your program you can now type

java HelloWorld

Page 64: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 64

A bit more complex program

public class SimpleAdder {public static void main(String[] args) {

int x = 4 + 2;System.out.println("The value of x is");

System.out.println(x);}

}

What do you think this does?

Page 65: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 65

Exercises to practice this at home• A) Practice breaking the following tasks into smaller

pieces. Make sure the pieces are small enough that you can manage them.

• 1)Choosing what channel to watch on TV• 2)Writing a 5 paragraph essay• 3)Studying for an exam• 4)Arguing a speeding ticket in court• B) Look at the resources on the course website and try

to compile the HelloWorld program written 2 slides back.• Note: The file MUST be called HelloWorld.java (case-

sensitive) or else the program will not compile

Page 66: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 66

Interesting problem to think about

• Suppose you know that your friend will flash 1001 numbers (one at a time) on a screen

• You don't have any paper but you do have a very basic calculator (which can store 1 number using the M+ button)

• Furthermore, your friend tells you that every number from 1 to 1000 will appear in his numbers at least once.

• Your task is to figure out what the 1001st number is.

• What would be a good way to do this?

Page 67: COMP-202 Unit 0: Course Details - McGill University School ...cs202/2012-01/web/... · Coordinates and Office Hours •McConnell Eng. Building, Room 326 •Office Hours: –Thursdays:

CO

MP 202 –

Introduction to Com

puting 1

COMP‐202 ‐ Course Details 67

Next Class

• Basics of Java and how computers work