Java and Software Design: Introduction To
Java and Software Design: Introduction To
Weems
Headington
Slides by Sylvia Sorkin, The Community College of Baltimore County - Essex Campus
Chapter 1 Topics
Computer Programming Programming Life-Cycle Phases Developing an Algorithm Machine Language vs. High Level Languages Compilation, Execution and Interpretation Computer Components Computing Profession Ethics and Responsibilities Problem-Solving Techniques
2
It is the process of specifying the data types and the operations for a computer to apply to data in order to solve a problem.
STEP 1 STEP 2 STEP 3 . . .
3
3 Maintenance
Problem-Solving Phase
ANALYZE the problem and SPECIFY what the solution must do.
Develop a GENERAL SOLUTION (ALGORITHM) to solve the problem. VERIFY that your solution really solves the problem.
Sample Problem
otherwise,
8
An Algorithm is . . .
step-by-step instructions for solving a problem in a finite amount of time using a finite amount of data.
10
It is a language with strict grammatical rules, symbols, and special words used to construct a computer program.
11
Translating your algorithm into a programming language is called CODING. With Java, you use Documentation -- your written comments
Compiler -- translates your program into Bytecode Java Virtual Machine -- translates Bytecode into machine language
12
TESTING your program means executing (running) your program on the computer, to see if it produces correct results.
If it does not, then you must find out what is wrong with your program or algorithm and fix it. This is called debugging.
13
Maintenance Phase
USE and MODIFY the program to meet changing requirements or correct errors that show up in using it.
Maintenance begins when your program is put into use and accounts for the majority of effort on most programs.
14
2 Implementation
Concrete Solution ( Program ) Test
3 Maintenance
Use Maintain
15
Programming Shortcut?
18
Machine Language
Is not portable Runs only on specific type of computer Is made up of binary-coded instructions (strings of 0s and 1s) Is the language that can be directly used by the computer.
19
Assembly Language
Is machine dependent. Compilers translate assembly language into machine language. Runs only on specific type of computer.
20
Are portable. Generally compilers translate high-level language into machine language. User writes program in language similar to natural language. Examples -- FORTRAN, COBOL, Pascal, C, C++ Many are standardized by ISO/ANSI to provide an official description of the language.
21
SOURCE
written in C++
OBJECT
written in machine language
via compiler
via linker
Java Portability
EXECUTABLES Payroll.java SOURCE Java Program Payroll.class BYTECODE
Windows PC running JVM
Achieves portability by using both a compiler and an interpreter. First, a Java compiler translates a Java program into an intermediate Bytecode--not machine language. Then, an interpreter program called the Java Virtual Machine (JVM) translates a single instruction in the Bytecode program to machine language and immediately runs it, one at a time.
24
A sequence is a series of statements that executes one after another. Selection (branch) executes different statements depending on certain conditions. Loop (repetition) repeats statements while certain conditions are met. A subprogram breaks the program into smaller units. Asynchronous control handles events that originate outside our program, such as button clicks.
25
SEQUENCE
Statement
Statement
Statement
...
26
SELECTION (branch)
IF Condition THEN Statement1 ELSE Statement2
Statement1
Statement Condition
Statement2
...
27
LOOP (repetition)
WHILE Condition DO Statement1
False Condition
...
Statement
28
SUBPROGRAM (function)
SUBPROGRAM1
...
29
ASYNCHRONOUS CONTROL
30
Object-Oriented Programming
31
An Object of class
OPERATIONS
Set Increment Write
. . .
Time
DATA
Time
32
33
Memory Unit
34
Arithmetic/Logic Unit performs arithmetic operations, and makes logical operations. Control Unit controls the order in which your program instructions are executed.
35
Peripheral Devices
36
Copy software only with permission from the copyright holder. Give credit to another programmer by name whenever using his/her code. Use computer resources only with permission. Guard the privacy of confidential data. Use software engineering principles to develop software free from errors.
37
ASK QUESTIONS -- about the data, the process, the output, error conditions. LOOK FOR FAMILIAR THINGS -- certain situations arise again and again. SOLVE BY ANALOGY -- it may give you a place to start.
USE MEANS-ENDS ANALYSIS -- Determine the I/O and then work out the details.
38
DIVIDE AND CONQUER -- break up large problems into manageable units. BUILDING-BLOCK APPPROACH -- can you solve small pieces of the problem? MERGE SOLUTIONS -- instead of joining them end to end to avoid duplicate steps.
1. Save inside a file named test.java 2. To compile: javac test.java (produces test.class) 3. To execute: java test (executes test.class) 1. Prints out Welcome World! to the screen
40