computer programmingricci/cp/slides/1-intro-cp.pdf · 2019-10-08 · goals pteach the fundamental...

20
Computer Programming and Introduction to Programming Francesco Ricci Free University of Bozen-Bolzano 2020/2021

Upload: others

Post on 12-Aug-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Computer Programmingricci/CP/slides/1-Intro-CP.pdf · 2019-10-08 · Goals pTeach the fundamental principles of programming nthe process of designing, writing, testing, debugging,

Computer Programmingand

Introduction to Programming

Francesco RicciFree University of Bozen-Bolzano

2020/2021

Page 2: Computer Programmingricci/CP/slides/1-Intro-CP.pdf · 2019-10-08 · Goals pTeach the fundamental principles of programming nthe process of designing, writing, testing, debugging,

Francesco Riccip ‘79-’85 Mathematics at Padova Univ. and Scuola

Normale Superiore, Pisa

p ’86-’87 Software analyst and programmer (EnichemS.p.A., Milano)

p ‘88-’98 Director of research units (ITC-irst, Trento)

p ‘98-00 Software architect (Sodalia S.p.A. Trento)

p ‘00-06 Director of Electronic Commerce and Tourism Research Center (Trento)

p ’05 Spin off https://www.suggesto.eu

p ‘06-now Professor at Free University of Bozen-Bolzano

p ’15-now Dean of the Faculty of Computer Science

https://scholar.google.it/citations?user=vK7a7K8AAAAJ

Page 3: Computer Programmingricci/CP/slides/1-Intro-CP.pdf · 2019-10-08 · Goals pTeach the fundamental principles of programming nthe process of designing, writing, testing, debugging,

Contact Details

p Francesco Riccin Room 2.17 (POS)n [email protected]

p Availability Hours:n Tuesday: 14:00 – 18:00n Preferably, by prior arrangement via e-

mailp Course web site

n http://www.inf.unibz.it/~ricci/CP/n https://ole.unibz.it/ (no access code)

Page 4: Computer Programmingricci/CP/slides/1-Intro-CP.pdf · 2019-10-08 · Goals pTeach the fundamental principles of programming nthe process of designing, writing, testing, debugging,

Course Structurep Lectures: 60 hoursp Labs: 30 hoursp Timetable:

n Lectures: Tuesday, Thursday and Friday 10:30 –12:30

n Labs 3h per week, divided into two slots (1h, 2h) Tuesday and Thursday (first lab on Oct 8th):p Francesco Barile (Comp Prog) and Michele

Segata (Intr Prog). Assistant David Massimop Assessment:

n final exam, written, 60% of the mark (16 points)n project (1 student per project !) 40% (14 points)n Assignments in the labs (3 points bonus).

Page 5: Computer Programmingricci/CP/slides/1-Intro-CP.pdf · 2019-10-08 · Goals pTeach the fundamental principles of programming nthe process of designing, writing, testing, debugging,

What is a computer program?

p A computer program is a set of instructions p What are the instructions so that the program

has a particular behaviour (solve a problem)?p Simple: program with the

instructions to exit a labyrinth

p Harder: program with theinstructions to exit from any labyrinth

p Instructions are given ina specific language (Java).

Page 6: Computer Programmingricci/CP/slides/1-Intro-CP.pdf · 2019-10-08 · Goals pTeach the fundamental principles of programming nthe process of designing, writing, testing, debugging,

Goalsp Teach the fundamental principles of programming

n the process of designing, writing, testing, debugging, and maintaining the source code of computer programs

p Source code is written in a programming languagep The purpose of programming is to create a program

that exhibits a certain desired behaviorp We will use an object-oriented approach: you will

learn how objects "speak" and "cooperate" to solve a problem

p You will learn how to solve problems with good programs - not only how to write programs but also how to design and implement effective solutions.

https://www.linkedin.com/learning/programming-foundations-fundamentals/what-is-programming

Page 7: Computer Programmingricci/CP/slides/1-Intro-CP.pdf · 2019-10-08 · Goals pTeach the fundamental principles of programming nthe process of designing, writing, testing, debugging,

How?p The learning will be based on examples, from very simple

ones to more complexn Build new solutions by reusing previously applied

solutions (Case-Based Reasoning) p We will use the Java 10 programming language (install JDK

first)p We will use an IDE Integrated Development Environment

(Eclipse): a software that provides comprehensive facilities to programmers for sw development

p This is a self-contained introduction to motivate further study and provide prerequisite material for more advanced courses on:n Programming Project (sem. 2), Computer Networks, Web

and Internet Engineering, ..

JDK and Eclipse are available for download in OLE

Page 8: Computer Programmingricci/CP/slides/1-Intro-CP.pdf · 2019-10-08 · Goals pTeach the fundamental principles of programming nthe process of designing, writing, testing, debugging,

What you should learn

p The fundamental principles of object-oriented programming,

p The use of control structures, functional abstraction, classes and methods, and basic data structures, …

p Be able to put them into practice, by writing good programs in Java that solve “simple” applicative problems:n EX1: an application for drawing and paintingn Ex2: an application for learning new English

words.

Page 9: Computer Programmingricci/CP/slides/1-Intro-CP.pdf · 2019-10-08 · Goals pTeach the fundamental principles of programming nthe process of designing, writing, testing, debugging,

Reading Code

static int fib(int n) {

if (n <= 1) return n;

return fib(n - 1) + fib(n - 2); }

https://youtu.be/IGJeGOw8TzQ

Page 10: Computer Programmingricci/CP/slides/1-Intro-CP.pdf · 2019-10-08 · Goals pTeach the fundamental principles of programming nthe process of designing, writing, testing, debugging,

Syllabus

p Introduction to computer systemsp Basic algorithms and data structuresp Data types and expressionsp Classes and objectsp Conditionals and loopsp Object-oriented designp Arrays and collectionsp Input/Output and exception handlingp Inheritance and polymorphismp Recursionp Building graphical user interfaces in Java.

Page 11: Computer Programmingricci/CP/slides/1-Intro-CP.pdf · 2019-10-08 · Goals pTeach the fundamental principles of programming nthe process of designing, writing, testing, debugging,

Why Java?p Python is even simpler (no compilation) but Java is

easier to read and understandp Debugging a Java program is easier compared with

C++ or Cp It is good for learning Object Oriented programming –

not for procedural programming p Java has a rich API (Application Program Interface) –

you can do graphics, sound or writing gamesp There is strong community supportp It is a strongly typed language (the compiler can

catch many newbie mistakes)p There is built-in Garbage Collector.

https://dev.to/javinpaul/why-java-is-the-best-programming-language-to-learn-coding-for-beginners-n89

Page 12: Computer Programmingricci/CP/slides/1-Intro-CP.pdf · 2019-10-08 · Goals pTeach the fundamental principles of programming nthe process of designing, writing, testing, debugging,

Course Formatp 10 Weeks on various topics in Programmingp 10 Labs

n Run, modify, understand yourself the examples (software) shown during the lectures

n Solve some new exercises/assignmentsn Build your own applicationsn Prepare yourself for your final exam project (based on

the assignments)p Books

n John Lewis and William Loftus, Java Software Solutions, Pearson, ed. 9, 2018.

n Java Tutorials – optional and more advanced - online (you can download it and read it on your computer) http://download.oracle.com/javase/tutorial/

Page 13: Computer Programmingricci/CP/slides/1-Intro-CP.pdf · 2019-10-08 · Goals pTeach the fundamental principles of programming nthe process of designing, writing, testing, debugging,

Exam Projectp The exam project is conducted individuallyp The objective is developing a java based

application:n With a graphical user interfacen That can manage items (music tracks, dvds,

trekking paths, soccer matches, cameras, …)p We will assign the precise task at a certain point in

time and you will deliver the solution before a deadline (e.g. in two weeks)

p We will evaluate the quality of the solution: easy to use, meaningfulness of the implemented functions, quality of the code (according to the principles that will be illustrated during the lectures).

Page 14: Computer Programmingricci/CP/slides/1-Intro-CP.pdf · 2019-10-08 · Goals pTeach the fundamental principles of programming nthe process of designing, writing, testing, debugging,

What a student must do to pass

p Read the book chapters (JSS) and additional material that will be suggested for each lecture

p Complete the “self-review questions” and “exercises” at the end of each section of the book (JSS) – self-review questions solutions are at the end of the book – exercises, ask me :-)

p The slides are enough only for a general understanding of the topic

p If something is not clear during a lecture you must take a note and rise a question (especially in the labs)

p Try what you see! Active Learningp Develop and test the programming assignmentsp Deliver the assignments and the project on time!

Page 15: Computer Programmingricci/CP/slides/1-Intro-CP.pdf · 2019-10-08 · Goals pTeach the fundamental principles of programming nthe process of designing, writing, testing, debugging,

Exam

p The final project package is typically delivered 2 weeks before the written exam (exact timing will be indicated)

p Written exam: questions and exercises on the topic illustrated in the lectures

p You cannot attend the written exam if you have not passed the project part

p You will have two grades: P (project), max 14 points, and W (written exam), max 17 points

p Lab Bonus: B<=3 is obtained if you deliver on time the (correct) assignments (it is optional)

p The final grade is F = W + min(P+B, 14)p P and W must be greater or equal than 8 and 10

respectively.

Page 16: Computer Programmingricci/CP/slides/1-Intro-CP.pdf · 2019-10-08 · Goals pTeach the fundamental principles of programming nthe process of designing, writing, testing, debugging,

The Best Ways to Studyp Based on a review of more than 700 scientific articles

on 10 commonly used learning techniquesp Self-Testing: Quizzing Yourself Gets High Marks

n Practice tests are done by students on their own, outside of class. Methods might include using flashcards (physical or digital) to test recall or answering the sample questions at the end of a textbook chapter

p Distributed Practice: For Best Results, Spread Your Study over Timen To remember something for one week, learning

episodes should be 12 to 24 hours apart; to remember something for five years, they should be spaced six to 12 months apart.

http://archive-e.blogspot.it/2013/08/psychologists-identify-best-ways-to.html

Page 17: Computer Programmingricci/CP/slides/1-Intro-CP.pdf · 2019-10-08 · Goals pTeach the fundamental principles of programming nthe process of designing, writing, testing, debugging,

Calibration Questionsp I am 90% confident that:1. Martin Luther King, Jr.'s age at death is between xxx and yyy. 2. The length of the Nile River, in km is between xxx and yyy.3. Between xxx and yyy countries belong to OPEC.4. There are between xxx and yyy books in the Old Testament.5. The diameter of the moon, in km is between xxx and yyy.6. The weight of an empty Boeing 747, in kg is between xxx and

yyy.7. Mozart was born between year xxx and yyy.8. The gestation period of an Asian elephant, in days is between xxx

and yyy9. The air distance from London to Tokyo, in km is between xxx and

yyy.10. The deepest known point in the ocean, in meters is between xxx

and yyy.

Page 18: Computer Programmingricci/CP/slides/1-Intro-CP.pdf · 2019-10-08 · Goals pTeach the fundamental principles of programming nthe process of designing, writing, testing, debugging,

Calibration Questions Answersp I am 90% confident that:1. Martin Luther King, Jr.'s age at death is between xxx and yyy. 392. The length of the Nile River, in km is between xxx and yyy. 66503. Between xxx and yyy countries belong to OPEC. 124. There are between xxx and yyy books in the Old Testament. 395. The diameter of the moon, in km is between xxx and yyy. 34746. The weight of an empty Boeing 747, in kg is between xxx and

yyy. 176,9017. Mozart was born between year xxx and yyy. 17568. The gestation period of an Asian elephant, in days is between xxx

and yyy. 6459. The air distance from London to Tokyo, in km is between xxx and

yyy. 9,59010. The deepest known point in the ocean, in meters is between xxx

and yyy. 10,970

Page 19: Computer Programmingricci/CP/slides/1-Intro-CP.pdf · 2019-10-08 · Goals pTeach the fundamental principles of programming nthe process of designing, writing, testing, debugging,

Results

• Blue distribution of correct replies is a typical observed one.• Green distribution is what it would look like if it were really the

case that every interval people gave had a 90% chance of containing the true answer.

http://messymatters.com/calibration/

Page 20: Computer Programmingricci/CP/slides/1-Intro-CP.pdf · 2019-10-08 · Goals pTeach the fundamental principles of programming nthe process of designing, writing, testing, debugging,

Classroom Etiquette

p Take responsibility for your educationp Get to class on timep Be attentive in classp Avoid side conversationsp Turn mobile phones offp Respect your instructorp Stay for the entire classp Your classmates deserve your respect and

supportp Come to class preparedp Turn in your work on time.