CS2200 Software Development Lecture 2: Java Program Development Lecturer: Adrian O’Riordan Course Webpage:

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

Chapter 1: Computer Systems
Object Oriented Programming in Java George Mason University Fall 2011
Dale Roberts Introduction to Java - First Program Dale Roberts, Lecturer Computer Science, IUPUI Department of Computer and.
JAVA BASICS SYNTAX, ERRORS, AND DEBUGGING. GCOC – A.P. Computer Science A College Board Computer Science A Topics Covered Program Design - Read and understand.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
How to Create a Java program CS115 Fall George Koutsogiannakis.
CS1061 C Programming Lecture 3: The Programming Environment + Introduction to the Concept of an Algorithm A. O’Riordan, 2004.
Java Intro. A First Java Program //The Hello, World! program in Java public class Hello { public static void main(String[] args) { System.out.println("Hello,
CS5651 CS556 Advanced Software Development Lectures 1 and 2 Lecturer: Adrian O’Riordan Office: Computer Science Prefab, Kane Building
Introduction to Java.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Introducing Java.
Chapter 1 Introduction.
Chapter 1 Programming Languages. Application Development: Top 10 Programming Languages to Keep You Employed 1. Java 2. C# 3. C++ 4. JavaScript 5. Visual.
(C) 2010 Pearson Education, Inc. All rights reserved.  Java programs normally go through five phases  edit  compile  load  verify  execute.
Basics Programming Concepts. Basics A computer program is a set of instructions to tell a computer what to do Machine language = circuit level language.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Chapter 1.4 Programming languages Homework Due: Monday, August 11, 2014.
1 Chapter 2 First Java Programs Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Session One Introduction. Personal Introduction Role of programmers Robot Examination HUD & HID Uploading Code.
© 2006 Pearson Education 1 Obj: cont 1.3 and 1.4, to become familiar with identifiers and to understand how programming languages work HW: p.51 #1.8 –
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
The Java Programming Language
Introduction. Objectives An overview of object-oriented concepts. Programming and programming languages An introduction to Java 1-2.
Jaeki Song ISQS6337 JAVA Lecture 03 Introduction to Java -The First Java Application-
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Intro and Review Welcome to Java. Introduction Java application programming Use tools from the JDK to compile and run programs. Videos at
Board Activity Find your seat on the seating chart Login – Remember your login is your first initial your last name and the last three numbers of your.
Programming Concept Chapter I Introduction to Java Programming.
CSCI Processing CSCI Introduction to Algorithm Design An Introduction.
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
FIRST JAVA PROGRAM. JAVA PROGRAMS Every program may consist of 1 or more classes. Syntax of a class: Each class can contain 1 or more methods. public.
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
4-Nov-15 Air Force Institute of Technology Electrical and Computer Engineering Object-Oriented Programming Design Topic 1: The Java Environment Maj Joel.
EIE375 BlueJ: Getting Started Dr Lawrence Cheung.
22-July-2002cse142-13B-Development © 2002 University of Washington1 Development Tools CSE 142, Summer 2002 Computer Programming 1
DrJava A lightweight pedagogic environment for Java Eric Allen, Robert Cartwright, and Brian Stoler Rice University
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
CS101: Introduction to Computer Science Slides adapted from Sedgewick and Wayne Copyright © Your First Java.
CSI 3125, Preliminaries, page 1 Compiling the Program.
CSc 201 Introduction to Java George Wells Room 007, Hamilton Building
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CSC 110 – INTRO TO COMPUTING - PROGRAMMING Overview of Programming.
Lecture1 Instructor: Amal Hussain ALshardy. Introduce students to the basics of writing software programs including variables, types, arrays, control.
Chapter 2 Wrap Up 2/18/16 & 2/22/16. Topics Review for Exam I DecimalFormat More Style Conventions Debugging using eclipse The Java API.
ITP 109 Week 2 Trina Gregory Introduction to Java.
CSCI 161 Lecture 3 Martin van Bommel. Operating System Program that acts as interface to other software and the underlying hardware Operating System Utilities.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
Java Programming Fifth Edition Chapter 1 Creating Your First Java Classes.
Introduction to 1. What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in The.
CS 201 Lecture 1 (b) Using an IDE Tarik Booker CS 201: Introduction to Programming California State University, Los Angeles.
1 Problem Solving  The purpose of writing a program is to solve a problem  The general steps in problem solving are: Understand the problem Dissect the.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
CS-140 Dick Steflik Lecture 3. Java C++ Interpreted optimized for the internet Runs on virtual ized machine Derived from C++ Good object model Widely.
CS210 Intermediate Computing with Data Structures (Java)
Lecture 1b- Introduction
The need for Programming Languages
Working with Java.
Before You Begin Nahla Abuel-ola /WIT.
Introduction to.
Programming without BlueJ Week 12
CompSci 230 Software Construction
Programming Vocabulary.
Introduction to Algorithm Design
Java Intro.
(Computer fundamental Lab)
Chap 1. Getting Started Objectives
Chap 4. Programming Fundamentals
Presentation transcript:

CS2200 Software Development Lecture 2: Java Program Development Lecturer: Adrian O’Riordan Course Webpage:

How do you develop software? Start with concept use a development process, e.g. design-code-test produce a good design † –procedural abstraction and data abstraction –high cohesion, low coupling produce readable code - self-documenting code using consistent coding conventions † Covered in separate lecture

Algorithm A formula or set of steps for solving a particular problem. In programming terms a set of instructions for solving a particular task. –Programming examples include sorting a list of names or searching for a record in a file. –Mathematics has many such procedures that are implemented as an algorithm: e.g. identify all prime numbers up to a given number (Sieve of Eratosthenes) The word algorithm in English comes from the Arab mathematician al- Khowarizmi who flourished at the end of the 8th Century A.D. (picture of al- Khowarizmi from Russian stamp)

Example Algorithm: Sieve of Eratosthenes 1.Write down the numbers 1, 2, 3,..., n. We will eliminate composites by marking them. Initially all numbers are unmarked. 2.Mark the number 1 as special (it is neither prime nor composite). a)Find the first number in the list greater than k that has not been identified as composite. (The very first number so found is 2.) Call it m. Mark the numbers 2m, 3m, 4m,... as Set k=1. Until k exceeds or equals the square root of n do this: b)composite. c)m is a prime number. Put it on your list. 3.Set k=m and repeat. 4.The list gives all the primes less than n.

Program Development Basics The basics of Java programming consist of specifying an algorithm and implementing this by writing Java program code. The program or source code is a set of instructions. E.g. HelloWorldApp.java A program can consist of one or more.java files. Normally one class per file /** * simply prints "Hello World!" to standard output. */ class HelloWorldApp { public static void main(String[] args) { System.out.println("Hello World!"); // Display the string. }

Example coding guidelines : Good use of variables Give sensible names to identifiers Use consistent style, e.g. carSpeed or car_speed Use each variable that you declare Initialise each variable properly Use each variable for one purpose only Minimise scope of identifiers Minimise duration of identifiers Minimise visibility of identifiers Use named constants (using final)

Java Programming Environment.java files compiled into a.class files, called bytecode. This is run on a JVM (Java Virtual Machine) such as Sun’s Hotspot. The bytecode is a standardized portable binary format. Multiple.class files can be packaged together into a.jar (Java archive). The JVM runtime executes.class or.jar files by emulating the JVM by interpreting it, or using a just-in-time compiler (JIT).

Compilation/Interpretation

Example: Using JDK Write your Java code in files – usually one class per file. Compile the code with javac. Fix the compile errors and recompile. When there are no more compile errors run the program wit the java command. Example: –Create a class Customer. Save in a file called Customer.java –Compile like so: prompt>javac Customer.java –And run like so: prompt>java Customer

Java IDEs IDEs (Integrated Development Environments) can widely available to speed up the process and provide increased support such as source code control, class browser, build-automation tools, and a debugger. Popular Professional Java IDEs include: NetBeans (Sun) Eclipse (Eclipse Foundation) JBuilder (CodeGear) JDeveloper (Oracle) Teaching and Learning (Interactive) IDEs BlueJ (bluej.org) Dr Java (drjava.org)

Eclipse IDE

Dr Java

Dr Java IDE DrJava (drjava.org) is a lightweight programming environment for Java designed specifically for beginners. DrJava supports the use of different Java compilers, such as the traditional javac compiler supplied with the JDK (versions 6, 5 or earlier). Dr Java has an interactions pane, where you can input Java expressions and statements and immediately see their results; Dr Java has a definitions pane, where you can enter and edit class definitions with support for brace matching, syntax highlighting, and automatic indenting.

Dr Java Features Features include: –Text editing with syntax highlighting, brace matching, line numbers,find and replace –Buttons for compiling and running –Interactive interpreter - an extension of free DynamicJava –Integrated javadoc –Integrated debugger –Integrated JUnit –Project facility –Language level facility

Java APIs

Java Debugging A special program called a debugger can used to find errors (bugs). A debugger allows a programmer to stop a program at any point and examine and change the values of variables. An error or defect in software that causes a program to malfunction. A compiler error indicates something that must be fixed before the code can be compiled. Run-time errors only occur when you run a program, i.e. executable crashes. example: trying to divide by zero int scores = 500, num = 0, avg; avg = scores / num;