Units with – James tedder Unit 1: Programming Unit 2: Networking Unit 5: Security Jamestedder.net jamestedder@NWHC.ac.uk
Unit 1 -Programming Week 1
Unit 1: Programming Learning Outcomes LO1. Define basic algorithms to carry out an operation and outline the process of programming an application. LO2. Explain the characteristics of procedural, object-orientated and event- driven programming, conduct an analysis of a suitable Integrated Development Environment (IDE). LO3. Implement basic algorithms in code using an IDE. LO4. Determine the debugging process and explain the importance of a coding standard.
Assignments Assignment 1 – Programming basics and understanding algorithms Define basic algorithms to carry out an operation and outline the process of programming an application. Assignment 2 – Programming and IDE analysis Explain the characteristics of procedural, object-orientated and event-driven programming, conduct an analysis of a suitable Integrated Development Environment (IDE) Assignment 3 – Implement and test a basic algorithm Implement basic algorithms in code using an IDE Determine the debugging process and explain the importance of a coding standard
Welcome to Java! Java is Platform Independent, which means that you only need to write the program once to be able to run it on a number of different platforms! Java is portable, robust, and dynamic, with the ability to fit the needs of virtually any type of application. Java guarantees that you'll be able to Write Once, Run Anywhere.
Welcome to Java! Cont. More than 3 billion devices run Java. Java is used to develop apps for Google's Android OS, various Desktop Applications, such as media players, antivirus programs, Web Applications, Enterprise Applications (i.e. banking), and many more!
Java History Invented by James Gosling for Sun Microsystems First developed in 1990 Originally called Oak, renamed in 1994 Became freely available in 1995 Currently owned by Oracle.
Advantages of the java platform Easy to learn. Object-oriented. Platform-independent. Distributed. Secure. Robust. Multithreaded Distributed: Software that executes on two or more computers in a network. In a client-server environment, distributed applications have two parts: (1) the 'front end' that requires minimal computer resources and runs on the client computer(s), and (2) the 'back end' that requires large amounts of data crunching power and/or specialized hardware, and runs on a suitably equipped server computer. Read more: http://www.businessdictionary.com/definition/distributed-application.html Robust: Copes with errors well. Multi threaded: Can do lot’s of this at once.
Disadvantages of the java platform Performance: Java is comparatively slower and takes more memory space than the other native programming languages like C and C++.
Netbeans Integrated development environment for Java
Complete handout sheet 1 - Exercise 1 – Hello World Exercises Complete handout sheet 1 - Exercise 1 – Hello World
Syntax & standards
Java Program Structure In the Java programming language: A program is made up of one or more classes A class contains one or more methods A method contains program statements A Java application always contains a method called main main is the first method called when a Java application starts
Java Program Structure // comments about the class public class MyProgram { } class header class body Comments can be placed almost anywhere
Java Program Structure // comments about the class public class MyProgram { } // comments about the method public static void main (String[] args) { } method header method body
public static void main(String args[]) The method can be called from outside it’s class. Necessary because this method is being called by the Java runtime system which is not located in your current class. static Access modifier means we can call this method directly using class name without creating an object of it void Means the method does not return a value Java is platform independent language and if it will return some value then the value may mean different things to different platforms. main Name of the method. This name is fixed and as it's called by the JVM it’s the entry point for an application. String args[] These are the arguments of type String that your Java application accepts when you run it.
Identifiers Identifiers are the words a programmer uses in a program (variable names, class names, method names…) An identifier can be made up of letters, digits, the underscore character ( _ ), and the dollar sign Identifiers cannot begin with a digit Java is case sensitive - Total, total, and TOTAL are different identifiers By convention, programmers use different case styles for different types of identifiers, such as title case for class names - Lincoln upper case for constants - MAXIMUM
Reserved Words are predefined in the language, and cannot be used as identifiers The Java reserved words: abstract assert boolean break byte case catch char class const continue default do double else enum extends false final finally float for goto if implements import instanceof int interface long native new null package private protected public return short static strictfp super switch synchronized this throw throws transient true try void volatile while
White Space Spaces, blank lines, and tabs are called white space White space is used to separate words and symbols in a program Extra white space is ignored in Java A valid Java program can be formatted many ways Programs should be formatted to enhance readability, using consistent indentation
What value prints? public void test() { int myVar = 10; int MYVAR = 20; myVar = 35; System.out.println(“Value is:”+MYVAR); } A. 10 B. 20 C. 35 D. MYVAR
Complete handout sheet 1 – Section 6 Exercises a, b and c.