Object oriented programming

1,210 views
1,143 views

Published on

PT.BUZOO INDONESIA is No1 Japanese offshore development company in Indonesia.
We are professional of web solution and smartphone apps. We can support Japanese, English and Indonesia.
We are hiring now at http://buzoo.co.id/

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,210
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
60
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Object oriented programming

  1. 1. Lecture by Niko Adrianus Yuwono
  2. 2.  Objects are key to understanding object- oriented programming.  Objects are like real-world objects like cat or car  Real-world objects share two characteristics: They all have state and behavior.  For example cats have state (name, color, breed, hungry) and behavior (meowing, fetching, wagging tail, playing).
  3. 3.  Same as real-world object, object in programming also have that two characteristics : state (fields) and behavior (methods)  Hiding internal state and requiring all interaction to be performed through an object's methods is known as data encapsulation — a fundamental principle of object-oriented programming.
  4. 4.  In the real world, you'll often find many individual objects all of the same kind. There may be thousands of other cats in existence, but all of them have same state and behaviour.  That’s why we use class to classify them.  Objects of the same kind are said to be members of the same class.  Let’s say there are Angora Cat, Persian Cat and Common Cat. All of them are members of Cat class and they have same basic state and behaviour.
  5. 5.  Furthermore, if we want to make the classification bigger we can use Inheritance  Imagine a class with a very big scope let’s say we have a class named Animal that have fields legs, isHungry, isAlive, etc and methods eat, sleep, etc  The attribute in the class Animal can be inherited to their sub/child class
  6. 6.  For example we’ve a class named cats that extends to animal class  That means animal class is the parent/super class of cats class  Cat class will get all the same fields and methods as animal class  However, you must take care to properly document the state and behavior that each superclass defines, since that code will not appear in the source file of each subclass.
  7. 7.  This is a table of access member control that define which member of the class can be accessed Access Levels Modifier Class Package Subclass World public Y Y Y Y protected Y Y Y N no modifier Y Y N N private Y N N N
  8. 8.  Polymorphism describes a pattern in object oriented programming in which classes have different functionality while sharing a common interface.
  9. 9.  An interface is similar to a class except that it cannot contain code. An interface can define method names and arguments, but not the contents of the methods.  Any classes implementing an interface must implement all methods defined by the interface.
  10. 10.  Objective-C  @interface Forwarder : Object  {  id someFields;  }  - (id) someMethod;  @end
  11. 11.  PHP  interface InterfaceExample {  public function doSomething();  public function doEverything();  }
  12. 12.  Java  interface Animal{  void eat(String what);  void sleep(int time);  void mate(String withWho); }
  13. 13.  Method overloading deals with the notion of having two or more methods(functions) in the same class with the same name but different arguments.  While Method overriding means having two methods with the same arguments, but different implementation. One of them would exist in the Parent class (Base Class) while another will be in the derived class(Child Class).
  14. 14.  An abstract class is a mix between an interface and a class. It can define functionality as well as interface (in the form of abstract methods). Classes extending an abstract class must implement all of the abstract methods defined in the abstract class.
  15. 15.  PHP :  abstract class AbstractExample {  public $name;  public function doThis() {  // do this  }  abstract public function doThat();  }

×