730 likes | 883 Vues
CTIS251-Week 1 Engineering Software and Java Dr. Ozlem Albayrak. Menu. Introduction to the CTIS251 elements What is Engineering? Can we engineer software? Introduction to the java language programming concepts Primitive Data Types and Operations. Introduction to CTIS251.
E N D
CTIS251-Week 1 Engineering Software and Java Dr. Ozlem Albayrak
Menu • Introduction to the CTIS251 elements • What is Engineering? • Can we engineer software? • Introduction to the java language programming concepts • Primitive Data Types and Operations
Introduction to CTIS251 Course Elements: - Instructor - Students - Course Material
Instructor • Dr. Ozlem Albayrak • Computer Eng. Bilkent, 1992 • M.B.A., Bilkent, 1994 • M.S., UMCP, 1998 • Phd., Ankara, 2002 Room# 212 Phone: 290 5039 E-mail: ozlemal@bilkent.edu.tr
The Students • Attendance - Bonuses • Get to Know • Why are you here? • Expectations • Interests
Office Hour? Tuesday 14:40 – 15:30 Thursday 8:40 – 10:30 via e-mail or phone for appointment
Course Material Not limited to: • Syllabus • The main text book • References • All related high quality sources
Syllabus • Distributed syllabus will be reviewed • Subjects • Grading (bonus questions) • Labs
Webster’s Definitions en·gi·neer·ing ( n j -nîr ng) n. The application of scientific and mathematical principles to practical ends such as the design, manufacture, and operation of efficient and economical structures, machines, processes, and systems. Problem solvers
How is engineering software different from engineering bridges?
Continuous Calculus Testing/analysis is easy: if the bridge holds for 1M kg, it also probably holds 0.99Mkg Discrete Logic, Discrete Mathematics Testing/analysis is difficult Bridges Software
Made of physical stuff Some costs are obvious Changes after construction are hard Made of virtual stuff All costs are non-obvious Changes should be easy (but they’re not) Bridges Software for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { nextStates [i][j] = getCellAt (i, j).getNextState (); } }
Obvious when it fails Bridge makers get sued Architects need licenses Falls down quietly (usually) Software vendors blame user, charge for upgrades Anyone can make software, no one gets sued Bridges Software
Requirements are (usually) obvious and easy to describe A good design is apparent to everyone immediately Requirements are mysterious and hard to describe A good design is only apparent to “experts” but has impact later on GridDisplay Bridges Software CellAutomata Cell is a subtype of (extends) Grid ConwayLifeCell CellState
Google search about Java.... • Returns approximately yaklaşık 307.000.000 result!
Java Sources on the net • http://en.wikipedia.org/wiki/Java_%28programming_language%29 • http://java.net/ • http://java.sun.com/docs/books/tutorial/ • http://www.javaturkiye.com/ • Books: http://www.oreilly.com/pub/topic/java
What is Java? • Island in Indonesia known for coffee and volcanoes • A Programming Language (Java) • A Portable Low-Level Language (JVML) • A Platform (JavaVM) • A (semi-)successful marketing strategy • JavaScript is not related to Java or Java • All of the above
Compiling C++ Programs #include <stdio>main( int argc, char *argv[]) { // do something}
Hello.java class Hello { public static void main(String[] args) { System.out.println( “Hello World” );} Hello.class …Method Hello() 0 aload_0 1 invokespecial #1 <Method java.lang.Object()> 4 returnMethod void main(java.lang.String[]) 0 getstatic #2 <Field java.io.PrintStream out> 3 ldc #3 <String "Hello World!"> 5 invokevirtual #4 <Method void println(String)> 8 return The Java Virtual Machine javac
Hello.class Hello.class Hello.class The Java Virtual Machine class Hello { public static void main() { // do something} Win JVM Mac JVM Linux JVM
Java : Programming Language “A simple, object-oriented, distributed, interpreted, robust, secure, architecture neutral, portable, high-performance, multithreaded, and dynamic language.” [Sun95] By the end of the course, you should have a good idea if this is a true statement.
Platform Independence • C++ compiles to native code for a specific architecture (Linux, Windows…) • Java compiles to Java bytecode • Same bytecode runs on virtual machine for any platform • Only VM is platform specific • Good for downloadable code • Applets etc
Java • Syntax • Similar to C++ • Designed to be easy for C and C++ programmers to learn • Semantics (what programs mean) • Similar to Scheme • Designed to make it easier to reason about properties of programs
Programming Systems C++ Program Scheme Program C++ Compiler Scheme Interpreter Object Files Machine
Portability If you can implement a Java VM on your machine, then you can run all Java programs Security A VM can limit what programs can do to the real machine Simplicity VM instructions can be simpler than machine instructions Java VM Java Program Why use a virtual machine? Java Compiler Class Files Java Virtual Machine Machine
Programming in Java • Program is divided into classes • A class: • Defines a new datatype • Defines methods and state associated with that datatype • We call a value of a class datatype an object • Objects package state and code
Introduction toJava Programming with JBuilder, 3E Y. Daniel Liang
Course Objectives • Upon completing the course, you will understand • Create, compile, and run Java programs • Primitive data types • Java control flow • Methods • Arrays (for teaching Java in two semesters, this could be the end) • Object-oriented programming • Core Java frameworks (Swing, exception, I/O, collections, multithreading, multimedia, )
Course Objectives, cont. • You will be able to • Develop programs using various tools • Write simple programs using primitive data types, control statements, methods, and arrays • Understand object-oriented concepts and principles: abstraction, encapsulation, inheritance, and polymorphism • Develop a GUI interface and Java applets • Deal with exceptions in the program • Store and retrieve data using Java I/O • Use data structures from the Java Collections framework • Establish a firm foundation on Java concepts
Book Chapters • Part I: Fundamentals of Programming • Chapter 1 Introduction to Java and JBuilder • Chapter 2 Primitive Data Types and Operations • Chapter 3 Control Statements • Chapter 4 Methods • Chapter 5 Arrays
Book Chapters, cont. • Part II: Object-Oriented Programming • Chapter 6 Objects and Classes • Chapter 7 Strings • Chapter 8 Inheritance and Polymorphism • Chapter 9 Abstract Classes and Interfaces • Chapter 10 Object-Oriented Analysis and Design
Book Chapters, cont. • Part III: GUI Programming • Chapter 11 Getting Started with GUI Programming • Chapter 12 Event-Driven Programming • Chapter 13 Creating User Interfaces • Chapter 14 Applets
Book Chapters, cont. • Part IV: Developing Comprehensive Projects • Chapter 15 Exceptions and Assertions • Chapter 16 Input and Output • Chapter 17 Java Data Structures • Chapter 18 Multithreading • Chapter 19 Multimedia
Bonus Chapters on the CD-ROM • Part V: Bonus Chapters • Chapter 20 Internationalization • Chapter 21 Networking • Chapter 22 Database Programming • Chapter 18 Servlets • Chapter 19 JavaServer Pages
Chapter 1 Introduction to Java and JBuilder • What Is Java? • Getting Started With Java Programming • Create, Compile and Running a Java Application
What Is Java? • History • Characteristics of Java
History • James Gosling and Sun Microsystems • Oak • Java, May 20, 1995, Sun World • HotJava • The first Java-enabled Web browser • JDK Evolutions • J2SE, J2ME, and J2EE (not mentioned in the book, but could discuss here optionally)
Characteristics of Java • Java is simple • Java is object-oriented • Java is distributed • Java is interpreted • Java is robust • Java is secure • Java is architecture-neutral • Java is portable • Java’s performance • Java is multithreaded • Java is dynamic
JDK Versions • JDK 1.02 (1995) • JDK 1.1 (1996) • Java 2 SDK v 1.2 (a.k.a JDK 1.2, 1998) • Java 2 SDK v 1.3 (a.k.a JDK 1.3, 2000) • Java 2 SDK v 1.4 (a.k.a JDK 1.4, 2002) • ... • ...
JDK Editions • Java Standard Edition (J2SE) • J2SE can be used to develop client-side standalone applications or applets. • Java Enterprise Edition (J2EE) • J2EE can be used to develop server-side applications such as Java servlets and Java ServerPages. • Java Micro Edition (J2ME). • J2ME can be used to develop applications for mobile devices such as cell phones. This book uses J2SE to introduce Java programming.
Java IDE Tools • Forte by Sun MicroSystems • Borland JBuilder • Microsoft Visual J++ • WebGain Café • IBM Visual Age for Java • IBM WSAD
Getting Started with Java Programming • A Simple Java Application • Compiling Programs • Executing Applications
A Simple Application Example 1.1 //This application program prints Welcome //to Java! package chapter1; public class Welcome { public static void main(String[] args) { System.out.println("Welcome to Java!"); } } IMPORTANT NOTE: To run the program from the Run button, (1) set c:\jbuilder9\jdk1.4\bin on your path, and (2) copy both the slide directory and the example directory from the IR-CD to a directory (e.g., c:\LiangIR-CD) . Source Run
Anatomy of a Java Program • Comments • Package • Reserved words • Modifiers • Statements • Blocks • Classes • Methods • The main method