Introduction to Programming

Similar documents
Values, Variables, Types & Arithmetic Expressions. Agenda

Making Decisions. Agenda

Objects and Classes Lecture 1

Chapter 1. Introduction

SKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG)

Multimedia Programming with Java Getting Started

MEAP Edition Manning Early Access Program Get Programming with Java Version 1

Introduction to Computers and Java. Objectives. Outline. Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich.

Introduction to Computers and Java

Introduction to Computers and Java

Identifiers. Identifiers are the words a programmer uses in a program Some identifiers are already defined. Some are made up by the programmer:

Introduction to Computers and Java. Objectives. Outline. Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich.

Programming with Java

Lecture 1 - Introduction (Class Notes)

What is a programming language?

C++ Spring Break Packet 11 The Java Programming Language

Java Programming. Zheng-Liang Lu. Java 308 Spring Department of Computer Science & Information Engineering National Taiwan University

Lecture 1: Introduction to Java

Object-Oriented Programming Fall Robert Grimm, New York University

Inf1-OOP. Textbooks. Who and What. Organisational issues. Why Java? Course Overview. Hello, World! in Java

Objectives. Problem Solving. Introduction. An overview of object-oriented concepts. Programming and programming languages An introduction to Java

Educational Fusion. Implementing a Production Quality User Interface With JFC

1B1a Programming I Getting Started

Outline. CIS 110: Introduction to Computer Programming. What is Computer Science? What is computer programming? What is computer science?

COMP1007 Principles of Programming

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Object-Oriented Programming Fall Robert Grimm, New York University

CS 6371: Advanced Programming Languages

AP Computer Science A: Java Programming

Fundamentals of Programming. By Budditha Hettige

Chapter. Focus of the Course. Object-Oriented Software Development. program design, implementation, and testing

COMP 215: INTRO TO PROGRAM DESIGN. Prof. Chris Jermaine Chris Prof. Chris Dr. Chris

Introduction to Computers and Java

w3.ualg.pt/~jvo/poo

LECTURE 2. Compilers and Interpreters

9/11/08 (c) 2008 Matthew J. Rutherford Class (c) 2008 Matthew J. Rutherford Class

An Introduction to Software Engineering. David Greenstein Monta Vista High School

Scientific Computing

Week - 01 Lecture - 04 Downloading and installing Python

LECTURE 3 ADMINISTRATION SECTION -A

Component V Supporting Materials / Learn More Interesting Facts. Interesting Facts

Open and respond to this poll: PollEv.com/comp110. Calling Methods Mr. Roboto

Procedural programming. [verb-oriented] Tell the computer to do this. (Spring 2012)

Organization of Programming Languages (CSE452) Why are there so many programming languages? What makes a language successful?

MEMORIZE the Java App pick: public class { public static void main(string[] a) {

BASICS.

Objective: To learn meaning and concepts of programming. Outcome: By the end of this students should be able to describe the meaning of programming

The object-oriented approach goes a step further by providing tools for the programmer to represent elements in the problem space.

What is the Best Way for Children to Learn Computer Programming?

How to make a "hello world" program in Java with Eclipse *

Recap: Assignment as an Operator CS 112 Introduction to Programming

Object-Oriented Programming CSCI-UA

Welcome to CS120 Fall 2012

CSC 015: FUNDAMENTALS OF COMPUTER SCIENCE I

Java Programming. Zheng-Liang Lu. Java 301 Summer Department of Computer Science & Information Engineering National Taiwan University

Introduction to OOP Using Java Pearson Education, Inc. All rights reserved.

CS102 Unit 2. Sets and Mathematical Formalism Programming Languages and Simple Program Execution

Welcome to Introduction to Computer Science I

Computing and Programming

TTh 9.25 AM AM Strain 322

CompSci 125 Lecture 02

Slide 1 CS 170 Java Programming 1 Testing Karel

Introduction to Java

CS 112 Introduction to Programming

Lesson 01 Introduction

Lecture 1: Introduction to Java

Summer Assignment for the School Year

Lecture (01) Getting started. Dr. Ahmed ElShafee

Fundamentals of Programming. By Budditha Hettige

The NetBeans IDE is a big file --- a minimum of around 30 MB. After you have downloaded the file, simply execute the file to install the software.

Title: Counting While Loops

Introduction. Introduction to OOP with Java. Lecture 01: Introduction to OOP with Java - AKF Sep AbuKhleiF -

Technology in Action. Chapter Topics (cont.) Chapter Topics. Reasons for Software Programming. Information Systems 10/29/2010

The Environment Model. Nate Foster Spring 2018

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 2: SEP. 8TH INSTRUCTOR: JIAYIN WANG

Introduction to OOP with Java. Instructor: AbuKhleif, Mohammad Noor Sep 2017

CS1004: Intro to CS in Java, Spring 2005

CSE 142. Lecture 1 Course Introduction; Basic Java. Portions Copyright 2008 by Pearson Education

CS 116x Winter 2015 Craig S. Kaplan. Module 03 Graphical User Interfaces. Topics

Programming for Engineers in Python

An Overview of Visual Basic.NET: A History and a Demonstration

This course supports the assessment for Scripting and Programming Applications. The course covers 4 competencies and represents 4 competency units.

Introduction to Computers and Java

Fundamentals of Programming. Lecture 1: Introduction to C Programming

UNIVERSITI TEKNIKAL MALAYSIA MELAKA FACULTY INFORMATION TECHNOLOGY AND COMMUNICATION (FTMK) BITE 1513 GAME PROGRAMMING I.

An Introduction to Python (TEJ3M & TEJ4M)

Technology in Action. Chapter Topics. Scope creep occurs when: 3/20/2013. Information Systems include all EXCEPT the following:

COP4020 Programming Languages. Compilers and Interpreters Robert van Engelen & Chris Lacher

A PROGRAM IS A SEQUENCE of instructions that a computer can execute to

Object Oriented Concepts and Programming (CSC244) By Dr. Tabbasum Naz

Chapter 5 Methods. public class FirstMethod { public static void main(string[] args) { double x= -2.0, y; for (int i = 1; i <= 5; i++ ) { y = f( x );

CS 121 Intro to Programming:Java - Lecture 2. Professor Robert Moll (+ TAs) CS BLDG

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Lecture Notes on Programming Languages

Introduction to Computers and Java

Chapter 1 Introduction to Computers, Programs, and Java

AP Computer Science A

WELCOME! (download slides and.py files and follow along!) LECTURE 1

CHAPTER 1. Introduction to JAVA Programming

1.1 Your First Program

Transcription:

Introduction to Programming Lecture 1 Object-Oriented Programming Agenda What is Program? Ideal Computing Way Where We Are in Computers? Interaction with the Computer Where are we going? Programming and its aspects Course Objective Object-Oriented Programming Interpreting vs. Compiling Programs Java Program Development Cycle Programming Tools Learn Programming Scare of Programming First Java Program Readings Lecture 1 Object-Oriented Programming 2 1

What is a Program? Model of complex system model: simplified representation of salient features of something, either tangible or abstract system: collection of components that work closely together Sequences of instructions expressed in specific programming language: syntax: grammatical rules for forming instructions semantics: meaning/interpretation of instructions Instructions written (programmed/coded) by programmer coded in a specific programming language programming languages allow you to express yourself more precisely than natural language as a result, programs cannot be ambiguous all instructions together are called source code Executed by computer by carrying out individual instructions Real world example: library catalog, word processor, video game, ATM Lecture 1 Object-Oriented Programming 3 Two Views of a Program user interface software layers hidden by user interface user s view programmer s view Lecture 1 Object-Oriented Programming 4 2

The Ideal Way to Do Computing The ideal way to ask computer to do something is to order it in a natural language e.g. I want to view this webpage Calculate my annual tax etc. However, today s computer s are not intelligent enough to understand our orders in natural language. Lecture 1 Object-Oriented Programming 5 Where We Are in Computers? At the very basic level computers use the concept of an electrical pulse. Low voltage is represented as 0 High voltage is represented as 1 To instruct a computer we need ask the computer in the language of 0s and 1s commonly known as machine language. For instance 73 in a number in natural language in the language of 0s and 1s, it becomes 1001001 Lecture 1 Object-Oriented Programming 6 3

Machine Language: Our First Interaction with the Computer Finding an average of two numbers in machine language. 10110011 00011001 01111010 11010001 10010100 10011111 00011001 01011100 11010001 10010000 10111011 11010001 10010110 Not very intuitive way of working Not possible for humans to achieve a lot using machine language Lecture 1 Object-Oriented Programming 7 One Step Beyond Assembly Language One level above machine language is assembly language MOV 0, SUM MOV NUM, AC ADD SUM, AC STO SUM, TOT More understandable but still very difficult for many of us. An assembler translates assembly language into machine language. Lecture 1 Object-Oriented Programming 8 4

Another Step High-level Languages High-level languages is another level above machine language. X = (Y + Z) / 2 Much more understandable. A compiler translates high-level language into assembly language. Lecture 1 Object-Oriented Programming 9 Where are we going? Te next step in computing is to use natural language over a high-level language. But we are many many years away from it. A lot of research needs to be carried out before we actually see this. Until then our task is to use high-level languages in its best possible ways Lecture 1 Object-Oriented Programming 10 5

What is Programming? When we say programming we are actually referring to the science of transforming our intentions in a high-level programming language. Lecture 1 Object-Oriented Programming 11 Many Aspects of Programming Programming is controlling computer does exactly what you tell it to Programming is teaching computer can only learn to do new things if you tell it how Programming is problem solving always trying to make computer do something useful i.e., finding an optimal travel route Programming is creative must find a good solution out of many possibilities Programming is modelling describe salient (relevant) properties and behaviors of a system of components (objects) Programming is abstraction identify important features without getting lost in detail Programming is concrete must provide detailed instructions to complete task Lecture 1 Object-Oriented Programming 12 6

What are we doing in this course? Learn programming in a high-level programming language. Programming has many paradigms Procedural Object-Oriented Functional Logic We will study Object-Oriented Programming using Java, a popular high-level object-oriented programming language. Lecture 1 Object-Oriented Programming 13 Object-Oriented Programming OOP: Now the dominant way to program, yet it is almost 40 years old! (Simula 67 and Smalltalk 72 were the first OOPLs) Dr. Alan Kay received ACM's Turing Award, the "Nobel Prize of Computing, in 2003 for Smalltalk, the first complete dynamic OOPL It was slow to catch on, but since the mid-90 s everybody s been doing it! OOP emphasizes objects, which often reflect real-life objects have both properties and capabilities i.e., they can perform tasks: they know how to... Lecture 1 Object-Oriented Programming 14 7

OOP as Modeling In OOP, model program as collection of cooperating objects program behavior is determined by group interactions group interactions are determined by individual objects In OOP, objects are considered anthropomorphic each is smart in its specialty i.e., bed can make itself, door can open itself, menu can let selections be picked but, each must be told when to perform actions by another object so objects must cooperate to accomplish task Each object represents an abstraction a black box : hides details you do not care about allows you as the programmer to control program s complexity only think about salient features So, write programs by modeling problem as set of collaborating components you determine what the building blocks are then put them together so they cooperate properly like building with smart Legos that you design! Lecture 1 Object-Oriented Programming 15 Interpreting vs. Compiling Programs An alternative to compiling your program is to interpret your program each line of your program is translated into machine language and immediately executed Like translating between natural languages Compiler: human translator translates book in its entirety and then translated book is printed and read Interpreter: human interpreter translates each spoken statement in sequence as speaker is speaking Lecture 1 Object-Oriented Programming 16 8

Running Java Programs Java uses both compilation and interpretation in a two-step process Compiles program into bytecodes bytecode is close to machine language instructions, but not quite it is a generic machine language does not correspond to any particular machine Virtual Machine (VM) interprets bytecodes into native machine language and runs it different VM exists for different computers, since bytecode does not correspond to a real machine Same Java bytecodes can be used on different computers without re-compiling source code each VM interprets same bytecodes allows you to run Java programs by getting just bytecodes from Web page This makes Java code run cross-platform marketing says, Write once, run anywhere! true for pure Java, not for variants Lecture 1 Object-Oriented Programming 17 Java Program Development Cycle Lecture 1 Object-Oriented Programming 18 9

Programming Tools Key Tools for Programming Editors: Allows user to enter the program. Notepad, Emacs, etc are all editors. Compilers: Translates the program into target code (in machine language). Debuggers: Allows a programmer to run the program to see the execution of the program and correct any errors. Profilers: Used to evaluate program s performance. Integrated Development Environment (IDE): Combines editor, compiler, debugger and profiler or a subset into one tool. Common Java IDEs are Eclipse, Netbeans, BlueJ, and DrJava. We will use DrJava IDE for the programming assignments in this course. Lecture 1 Object-Oriented Programming 19 A Word of Caution IDEs, editors, debuggers, and other programming tools do not write program themselves. They merely provide some help in writing a program. Therefore, THERE IS NO SHORTCUT TO PROGRAMMING SKILLS AND EXPERIENCE. Lecture 1 Object-Oriented Programming 20 10

How to Learn Programming Everybody learns programming at their own pace. So do not be impressed by the person sitting next to you because he coded a given program in 20 minutes and you are taking more then an hour. Speed programming does not necessarily mean quality of the final output. Lecture 1 Object-Oriented Programming 21 How to Learn Programming (cont d) In a Nutshell 1. Writing a good description of the problem. 2. Breaking down the given problem into small pieces. 3. Turning small pieces into pseudo-code. 4. Deciding the integration mechanism of the pieces. 5. Writing the program for each piece. 6. Integrating all the pieces together. Lecture 1 Object-Oriented Programming 22 11

Scare of Programming? Why most students are afraid of programming Paradigm Change Programming is totally different paradigm. You are working on something and you cannot even touch the final output you can only feel it. It is different then other subjects like Physics, Chemistry, Biology, etc. Peer Pressure Some people are naturally good in programming so others think that this is a natural ability and they cannot learn it. Lecture 1 Object-Oriented Programming 23 Scare of Programming? (cont d) Lack of Understanding in Fundamental Concepts Some people start programming without a clue of what is going on behind the scene in the computer. As a result they have a flawed understanding from day one of their programming experience Time Factor: Programming takes a lot of time Programming may take a lot of time at the start but once a person is comfortable with the concepts and has mastered the basic skills it is just like any other profession. Lecture 1 Object-Oriented Programming 24 12

A Word of Advice Without good command on programming any qualification in Computer Science, Computer Engineering, Information Technology and Software Engineering is worthless. There is an acute shortage of programmers in the global software market and with time this shortage is increasing. Lecture 1 Object-Oriented Programming 25 First Java Program class First { } public static void main(string arg[]) { } System.out.println("Engr. M Haroon Yousaf welcomes you in OOP"); Lecture 1 Object-Oriented Programming 26 13

Readings Book Name: Object-oriented Programming in JavaTM Textbook Author: Richard L. Halterman Content: Chapter 1 Book Name: Object Oriented Programming in Java A Graphical Approach Author: Kathryn E. Sanders & Andries van Dam Content: Chapters 0 Lecture 1 Object-Oriented Programming 27 Acknowledgements While preparing this course I have greatly benefited from the material developed by the following people: Andy Van Dam (Brown University) Mark Sheldon (Wellesley College) Robert Sedgewick and Kevin Wayne (Princeton University) Mark Guzdial and Barbara Ericsson (Georgia Tech) Richard Halterman (Southern Adventist University) Lecture 1 Object-Oriented Programming 28 14