Presentation is loading. Please wait.

Presentation is loading. Please wait.

Centre for Computer Technology ICT214 Object Oriented Design and Programming Week 1 - Introduction Richard Salomon and Umesh Patel Centre for Information.

Similar presentations


Presentation on theme: "Centre for Computer Technology ICT214 Object Oriented Design and Programming Week 1 - Introduction Richard Salomon and Umesh Patel Centre for Information."— Presentation transcript:

1 Centre for Computer Technology ICT214 Object Oriented Design and Programming Week 1 - Introduction Richard Salomon and Umesh Patel Centre for Information and Communication Technology Box Hill Institute of TAFE

2 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Java Definition Java is: a simple, object oriented, network savvy, interpreted,robust, secure, architecture neutral,portable (platform independent), high performance, multi-threaded, dynamic language. Java is: a simple, object oriented, network savvy, interpreted,robust, secure, architecture neutral,portable (platform independent), high performance, multi-threaded, dynamic language.

3 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute History Java was developed primarily by SUN engineers named James Gosling and Patrick Naughton. Java was developed primarily by SUN engineers named James Gosling and Patrick Naughton. Original focus was on small consumer devices Original focus was on small consumer devices Growth of the Web and its write once, run anywhere ability made it the ubiquitous internet language that it is today. Growth of the Web and its write once, run anywhere ability made it the ubiquitous internet language that it is today. It was named *7 and Oak before the name Java was settled. It was named *7 and Oak before the name Java was settled. Initial version fitted on a 1.4M floppy, now it occupies 50 MB + Initial version fitted on a 1.4M floppy, now it occupies 50 MB +

4 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute What is Java? Java is an Object Oriented Programming [OOP] Language Java is a very popular language for building applications for the Web Java is robust, portable, architecture neutral, multithreaded “WORA” - Write Once Run Anywhere “WORM” – Write Once Run Many

5 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Java Byte-Code and Portability Java is and interpreted, application language J2SDK uses javac to compile the source code filename.java into bytecode file filename.class java runs the filename.class code on the JVM. Compile and Run Command

6 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Java Development and Runtime Environment Java Source Code (java) Java Byte Code (class) Java Compiler Java Byte Code moves locally to the JVM Java Class Loader and Byte Code Verifier Java Class Libraries Java Interpreter J-I-T Compiler Runtime System JVM Operating system Hardware

7 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Language Types Procedural - Basic, Pascal, C Event Driven – Visual Basic [VB] Object Oriented [OO] - C++, C#, Java Java’s major use - internet, web, e-commerce

8 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Objects and Actions object is anything world is a set of interacting objects objects have characteristics (attributes) and its value Instance – is an object that is used by an application objects have state with certain attributes and values objects have behaviour (actions - methods)

9 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Objects and Methods Method is a set of instruction describing the operations performed by an object An object is an entity that stores data and can take actions defined by methods A method is an action which can be performed by an object. The action takes place as the result of a method call also known a method invocation. The calling objects calls or invokes the method.

10 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Object-Oriented Programming java program – collection of classes class - collection of interacting objects object has its instances Encapsulation (Data Hiding) Inheritance Protection Reusability

11 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute JDK/SDK Utilities Found in the \bin directory javac, java, javah (allows incorporation of a native part in the code), jdb, javadoc, jar We will use the IDE - BlueJ, Netbeans

12 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Basic Language Elements Punctuation - the symbols that are used by a computer language Punctuation - the symbols that are used by a computer language Syntax - construction rules to code in that language Syntax - construction rules to code in that language Vocabulary - the language keywords Vocabulary - the language keywords Operators - Symbols or commands for processing data Operators - Symbols or commands for processing data Identifiers - symbols to reference data stored in memory of the computer Identifiers - symbols to reference data stored in memory of the computer

13 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Java Program Example /** * * HelloWorld.java * @author Richard * @version 1.0 */ public class HelloWorld { public static void main(String args []) { String name = “ Richard Salomon” ; System.out.println(“Hello World“); System.out.println(“\nMy name is ” + name + “\n”); } }

14 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Documentation Documentation can impact the success or failure of a project Documentation does two things: aid the design process communicate your design and describe your implementation to other programmers

15 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Good Design Documentation Meaningful name for variables Use Comments according to Java Coding Standards Indentation Named Constants Simple Program Structure Reduce class load

16 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Design Process I. I. Comments serve as the first step of class design II. II. Turn comments into pseudocode III. III. Refine pseudocode into java code IV. IV. Comments help with debugging

17 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Comments // single line comment /* block comment over many lines */

18 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Comments /** java doc comment, used by the javadoc tool. Can include single line comments and html tags. eg monos paced text Some html tags cause problems in javadoc eg header and frame tags All javadoc comments must be placed before declarations. Javadoc comments placed within code braces will be ignored by the javadoc tool */

19 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Comments Best to start program development with comments rather than spending a lot of time after the code is written. Why? Best to start program development with comments rather than spending a lot of time after the code is written. Why? Java documentation is available at java.sun.com/docs and should be installed in the jdk#.#.#/doc directory Java documentation is available at java.sun.com/docs and should be installed in the jdk#.#.#/doc directory

20 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Elements Java is case sensitive; FRED differs from fred and also from Fred Keywords – must be lower case there are 48 keywords NB true, false, null are literals, not keywords Identifiers – labels for data – first character must be alpha – no space – case sensitive – no keywords

21 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Elements Operators braces { } brackets[ ] parenthesis( ) white space Operators braces { } brackets[ ] parenthesis( ) white space e.g. int myInteger = 27 ; e.g. int myInteger = 27 ; keyword identifier assignment operator literal terminator

22 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Data Storage Registers -space within CPU Registers -space within CPU The stack -method variables in RAM The stack -method variables in RAM The heap -objects in RAM The heap -objects in RAM Static storage – shared method or variable Static storage – shared method or variable Constant - non-changing variable in RAM Constant - non-changing variable in RAM Non-RAM storage – disk space Non-RAM storage – disk space

23 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Variables Variables represent data in storage locations in memory The data stored by a variable is called its value The value is stored in the memory location The value can be changed. Variable consist of 5 parts - identifier (name) - reference (memory address) - data type - scope (lifespan) - value (literal)

24 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Data Type Data type tells the compiler how to interpret and store the data. Data type tells the compiler how to interpret and store the data. It described the type of an attribute (field) It described the type of an attribute (field) Java allocates a set amount of storage to each type of data. Thus Java is strongly typed – Assignment Compatibilities Java allocates a set amount of storage to each type of data. Thus Java is strongly typed – Assignment Compatibilities

25 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Java Data Types Primitive data types Reference booleancharnumeric Integral floating point byteshortlongint floatdouble

26 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Data Type Storage boolean – 1 bit true/false boolean – 1 bit true/false char - 16 bits unicode char - 16 bits unicode byte - 8 bits -128 to +127 byte - 8 bits -128 to +127 short - 16 bits -32768 to +32767 short - 16 bits -32768 to +32767 int - 32 bits - 2 31 to +2 31 -1 int - 32 bits - 2 31 to +2 31 -1 long - 64 bits -9 x 10 18 to +9 x 10 18 long - 64 bits -9 x 10 18 to +9 x 10 18 float - 32 bits up to 7 decimal places float - 32 bits up to 7 decimal places double - 64 bits up to 14 decimal places double - 64 bits up to 14 decimal places

27 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Object data default values Data typeDefault values byte0 short0 int0 long0 float0.0 double0.0 booleanfalse char\u0000 referencenull

28 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Assignment assignment statement used to assign a value to a variable Operator is “=“ example lastName = ‘citizen’; special operators can be combined with arithmetic operators (+, -, *, %)

29 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Naming Conventions Class types begin with an uppercase letter Primitive types begin with a lowercase letter Variables of both class and primitive types begin with a lowercase letters Java Class Naming Conventions Must begin with a letter of any alphabet Can contain only letters, digits, underscores, or $ signs Can not be a Java keyword or literal Case sensitive Start with an upper case letter and then use lower case letters, with the first character of a new word capitalised e.g. Person, MotorVehicle a file may have many classes but only one public class file name must match the public class name

30 12 October 201512 October 201512 October 2015 Copyright Box Hill Institute Other Issues Simple Input / Output Named and Numbered Constants Initialisation Parenthesis and Precedence Increment / Decrement Operators


Download ppt "Centre for Computer Technology ICT214 Object Oriented Design and Programming Week 1 - Introduction Richard Salomon and Umesh Patel Centre for Information."

Similar presentations


Ads by Google