* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Object Oriented Paradigm
Library (computing) wikipedia , lookup
Class (computer programming) wikipedia , lookup
Resource management (computing) wikipedia , lookup
C Sharp syntax wikipedia , lookup
Application Interface Specification wikipedia , lookup
Object-relational impedance mismatch wikipedia , lookup
C Sharp (programming language) wikipedia , lookup
Design Patterns wikipedia , lookup
Object Oriented Paradigm Programming Paradigms En Mohd Norafizal A.Aziz Contents Definition of object oriented Basic concepts Objects Classes Messages Encapsulation Inheritances Abstract classes and Interfaces Polymorphism Sample of code Conclusion Blind man and Elephant What is Object Oriented Allows programmers to write computer programs by representing elements of a real-world problem in the form of so-called objects. Objects are represent both: behaviors of real world objects as well as their characteristics. All work in this concepts are using messages. Advantages of Object Oriented OOP provides a clear modular structure for programs. OOP is easy to maintain. OOP provides a good framework for code libraries. Objects Objects are the physical and conceptual things we find in the universe around us. Hardware, software, documents, human beings, and even concepts are all examples of objects. Objects are thought of as having state. The state of an object is the condition of the object, or a set of circumstances describing the object. However, it is possible for some objects to change their own state. If an object is capable of spontaneously changing its own state, we refer to it as an “object with life”. Objects is … An objects has a state, exhibits some well defined behavior and has a unique identity. Generally, OOP approach may be seen as manipulation with multiple objects. Programmers can : Create new objects Send message to existing objects Collect responses in a form of objects to which other messages may be sent. Sample of coding BankAccount myAccount = new BankAccount (); String myname = new String (‘Fizal’); Employee meAsemployee = new Employee (myname, myAccount); Consists of three fundamentals part : Variable declaration – Instantiation -- Initialization Classes A class represent a set of objects that share common structure and a common behavior. Example: CAR State ( gear, speed, etc) Behavior (change gear, accelerate etc) Classes is … Is a prototype that defines variables and methods that are common to all objects of the same kind. Sample of coding Public class Employee { // variables private String Name; private BankAccount B_Account; // methods public String salary (int sum) { // method body } } Public class Name { private String nama; public Name () // default constructor {} public Name (String nama) { this.nama = nama; } String getNama() { return nama; } void setNama(String Nama) { this.nama = nama; } public String toString() { return nama } } class { int int int Bicycle cadence = 0; speed = 0; gear = 1; void changeCadence(int newValue) { cadence = newValue; } void changeGear(int newValue) { gear = newValue; } void speedUp(int increment) { speed = speed + increment; } void applyBrakes(int decrement) { speed = speed - decrement; } void printStates() { System.out.println("cadence:"+cadence+" speed:"+speed+" gear:"+gear); } } Import java.io; Public class hello { public static void main (String args []) { System.out.pritnln(“Hello…World”); } } Messages Single objects are not very useful. Instead, an object usually appears as just one object of an object-oriented program that contains many objects. In such program all works is done by interaction between these objects. Sample of messages Employee meAsemployee = new Employee(myname, myAccount); meAsemployee.salary(1000); References Java Tutorials: http://java.sun.com/docs/books/tutorial/java/concepts/ Wikipedia: http://en.wikipedia.org/wiki/Object-oriented_programming Keywords: object oriented concepts in java with examples. Object Oriented concepts