Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to Java &.NET SEAP/BTIS/DB&I/Aug 2010 1 Introduction to Java &.NET  A step to equip our team with the OO programming basics  An initiative.

Similar presentations


Presentation on theme: "Introduction to Java &.NET SEAP/BTIS/DB&I/Aug 2010 1 Introduction to Java &.NET  A step to equip our team with the OO programming basics  An initiative."— Presentation transcript:

1 Introduction to Java &.NET SEAP/BTIS/DB&I/Aug 2010 1 Introduction to Java &.NET  A step to equip our team with the OO programming basics  An initiative to realize our values FAST Session 1

2 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 2 Agenda 1. Introduction 2. Java,.NET, and Procedural Languages 3.Object Oriented Basics

3 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 3 1. Introduction

4 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 4 Introduction Benefits a) broaden our knowledge by keeping up with the trend b) understand and support project programming phases Objectives a) realize the benefits set forth b) able to test change existing programs in our department Difficulties a) none of us come from OO programming background b) your contribution is necessary to continue the session d) training touches surface only d) commit time to further study

5 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 5 Introduction TaskAugSepOctNovDecJan - Mar 1: Introduction & OOZhang 2: Java Basics (1) Zhang 3: Java Basics (2) Zhang 4: Visio Studio ? 5: C# Introduction ? 6: VB (1) VBScript ? 7: VB (2) ? 8: Recode program

6 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 6 2. Java,.NET, and Procedural Languages

7 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 7 What is Java Java is a programming language and computing platform first released by Sun Microsystems in 1995. (Now belong to Oracle.) It is the underlying technology that powers state-of-the-art programs including utilities, games, and business applications. Java runs on more than 850 million personal computers worldwide, and on billions of devices worldwide, including mobile and TV devices. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to bytecode (class file) that can run on any Java Virtual Machine (JVM) regardless of computer architecture. Java is general-purpose, concurrent, class-based, and object-oriented, and is specifically designed to have as few implementation dependencies as possible. It is intended to let application developers "write once, run anywhere".

8 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 8 What is Java One characteristic of Java is portability, which means that computer programs written in the Java language must run similarly on any supported hardware/operating-system platform. This is achieved by compiling the Java language code to an intermediate representation called Java bytecode, instead of directly to platform-specific machine code. Java bytecode instructions are analogous to machine code, but are intended to be interpreted by a virtual machine (VM) written specifically for the host hardware. End-users commonly use a Java Runtime Environment (JRE) installed on their own machine for standalone Java applications, or in a Web browser for Java applets.

9 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 9 What is.NET The Microsoft.NET Framework is a software framework that can be installed on computers running Microsoft Windows operating systems. It includes a large library of coded solutions to common programming problems and a virtual machine that manages the execution of programs written specifically for the framework. The.NET Framework supports multiple programming languages in a manner that allows language interoperability, whereby each language can utilize code written in other languages; in particular, the.NET library is available to all the programming languages that.NET encompasses. The.NET Framework is a Microsoft offering and is intended to be used by most new applications created for the Windows platform.

10 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 10 What is.NET.NET and JVM are different. Java byte code isn't compatible with.NET byte code.

11 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 11 Procedural Languages e.g. FORTRAN, C, BASIC, Pascal, PL/SQL, etc Characteristics: Data is contained in data structures directly accessed by routines Data structures are separated from the routines’ code Different code modules access and modify the same data structures Data structures and code have different owners We may eventually lose knowledge of which code uses which data structure

12 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 12 Difference Between OOL & PPL A major factor in the invention of Object-Oriented approach is to remove some of the flaws encountered with the procedural approach. Object Orientation Languages (OOL) is concerned to develop an application based on real time while Procedural Programming Languages (PPL) are more concerned with the processing of procedures and functions. In OOL, more emphasis is given on data rather than procedures, while the programs are divided into Objects and the data is encapsulated (Hidden) from the external environment, providing more security to data which is not applicable or rather possible in PPL. In PPL, its possible to expose Data and/or variables to the external entities which is STRICTLY restricted IN OOL. In OOL, the Objects communicate with each other via Functions while there is no communication in PPL rather its simply a passing values to the Arguments to the Functions and / or procedures. OOL follows Bottom Up Approach of Program Execution while in PPL its Top Down approach. OOL concepts includes Inheritance, Encapsulation and Data Abstraction, Late Binding, Polymorphism, Multithreading, and Message Passing while PPL is simply a programming in a traditional way of calling functions and returning values. Source: www.wikianswers.com

13 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 13 3. Object Oriented Basics

14 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 14 Why OO? A technology that strongly ties data structures to the code routines that relate to them, fusing them into objects Offers a good methodological framework for software engineering Provides the foundation for systematic software engineering Objects relate to the “real world” more closely than modules of routines Encourage better modeling and implementation of systems. Provide a focus throughout analysis, design, and implementation Emphasize state, behavior, and interaction Benefits of OO programming: Reusability Stability Reliability Data Hiding Faster Design Easier maintenance Design Independence

15 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 15 OO Building Blocks There are differences between different OO languages, but general building blocks are: Objects With individual characteristics Classes Objects belong to a type Associations Objects know about each other and communicate with each other Inheritance A type may be a specialization of another type. Polymorphism A specialized type can be treated in a generic way

16 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 16 UML – Unified Modelling Language This object-oriented system of notation has evolved from the work of Grady Booch, James Rumbaugh, Ivar Jacobson, and the Rational Software Corporation.Rational Software Corporation These renowned computer scientists fused their respective technologies into a single, standardized model. Today, UML is accepted by the Object Management Group (OMG) as the standard for modeling object oriented programs.Object Management Group (OMG) Types of UML Diagrams UML defines nine types of diagrams: class (package), object, use case, sequence, collaboration, statechart, activity, component, and deployment. Source: http://www.smartdraw.com/resources/tutorials/uml-diagrams/

17 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 17 Example

18 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 18 Example

19 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 19 Terminology Object: A thing that exists in the domain of the problem E.g. An office building might have a number of ‘Elevators’, ‘Offices’, ‘SecurityDoors’, etc. Object Oriented: Software is object-oriented if the design and implementation of that software is based on the interaction between the objects of the domain Class: A template used for the creation of objects A class describes various attributes an object might have e.g. A ‘Person’ class might have various attributes, including age, weight, height, eye colour, address, etc.

20 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 20 Objects and Classes Bank Account A class (the concept) John’s Bank Account Balance: $5,257 An object (the realization) Bill’s Bank Account Balance: $1,245,069 Mary’s Bank Account Balance: $16,833 Multiple objects from the same class

21 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 21 Example of a Class class Employee { // Fields private String name; //Can get but not change private double salary; // Cannot get or set // Constructor Employee(String n, double s) { name = n; salary = s; } // Methods void pay () { System.out.println("Pay to the order of " + name + " $" + salary); } public String getName() { return name; } // getter }

22 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 22 Association (“has-a”) public class AntiAirCraftGun { private Bomber target; private int positionX; private int positionY; private int damage; public void setTarget(Bomber newTarget) { this.target = newTarget; } //rest of AntiAircraftGun class } public class Bomber { private AntiAirCraftGun target; private int positionX; private int positionY; private int damage; public void setTarget(AntiAirCraftGun newTarget) { this.target = newTarget; } //rest of Bomber class }

23 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 23 Association - Composition Composition gives us a 'part-of' relationship. Within composition, the lifetime of the part (Engine) is managed by the whole (Car), in other words, when Car is destroyed, Engine is destroyed along with it. public class Engine {... } public class Car { Engine e = new Engine();....... } As you can see in the example code above, Car manages the lifetime of Engine.

24 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 24 Association - Aggregation Within aggregation, the lifetime of the part is not managed by the whole. public class Address {... } public class Person { private Address address; public Person(Address address) { this.address = address; }... } Person would then be used as follows: Address address = new Address(); Person person = new Person(address); or Person person = new Person( new Address() );

25 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 25 Inheritance Inheritance is the process by which one object acquires the properties of another object. By use of inheritance, an object need only define all of its characteristics that make it unique within its class, it can inherit its general attributes from its parent. Account Checking Mortgage Loan In C# there may be more than one root In C# an object may have more than one parent (immediate superclass) But, Java has a single, strict hierarchy

26 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 26 Inheritance

27 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 27 Inheritance

28 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 28 Interface

29 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 29 Polymorphism Classical paradigm Must explicitly invoke correct version Polymorphism(from Greek, meaning“many forms”) is a feature that allows one interface to be used for a general class of actions, i.e. one interface, multiple methods.

30 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 30 Polymorphism Object-oriented paradigm All that is needed is myFile.open() Correct method invoked at run-time (dynamically) Method open can be applied to objects of different classes

31 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 31  Overriding  Overloading  Genericity public class MyListUtils { ArrayList copy(T[] list) { ArrayList list2 = new ArrayList (); for (int i = 0; i < obj.length; i++) list2.add(list[i]); return false; } Polymorphism

32 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 32 Another Example

33 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 33 Further Studies And vast resources over Internet and Library books, such as: http://www.youtube.com/watch?v=C2hSJOS9pkshttp://www.youtube.com/watch?v=C2hSJOS9pks -> Introduction to UML http://www.youtube.com/watch?v=NtfJxA1J3h8http://www.youtube.com/watch?v=NtfJxA1J3h8 -> OO Programming

34 Introduction to Java and.NET SEAP/BTIS/DB&I/Aug 2010 34 Thank You!


Download ppt "Introduction to Java &.NET SEAP/BTIS/DB&I/Aug 2010 1 Introduction to Java &.NET  A step to equip our team with the OO programming basics  An initiative."

Similar presentations


Ads by Google