OOPS features using Objective C

  • 4,512 views
Uploaded on

There is an explanation of why OOPs and then there is detailing on how OOPs is used by Objective C.

There is an explanation of why OOPs and then there is detailing on how OOPs is used by Objective C.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
4,512
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
91
Comments
0
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Tiyasi Acharya
  • 2. Why OOPs?• Spaghetti code.• Mass of tangled jumps and conditional branches.• Not designed for efficiency.
  • 3. PerformanceTime/Size Complexity
  • 4. Performance OOPsTime/Size Complexity
  • 5. How did OOPs come into the picture? Abstraction‘Emulate the working of a brain’ ‘Abstract out the details’
  • 6. Internal Model of a Car
  • 7. Internal Model of a CarThis is what computer scientists tried to bring into OOPs- ABSTRACTION!
  • 8. Abstraction
  • 9. AbstractionThis is how the human brain handles the complexity of the world.
  • 10. AbstractionThis is how the human brain handles the complexity of the world. How is this achieved in OOPs?
  • 11. InheritanceProcess by which 1 object acquires the properties of another object. Super Class: Four-wheeler Vehicles Sub Class: Truck, Car, Bus.
  • 12. Encapsulation“Hides” incredible amount of complexity by encapsulating it.
  • 13. EncapsulationWhat was it hiding?
  • 14. PolymorphismA feature that allows 1 interface to be used for a general class of actions. Steering Wheel Power Steering Wheel Steering wheel of an Electric car
  • 15. Another example of Polymorphism Dog Smell
  • 16. Class and Objects
  • 17. OOPs in Objective C
  • 18. Class and ObjectsA class consists of members: data and methods. Class Name@interface Employee: NSObject{ int empId; char *name; Members: Data}-(int) empId; Members: Methods-(int)lengthOfService:date;@end
  • 19. Objectsid date=[ [ Date alloc ] init ]; New Date object allocated[ date release]; Releasing the variable
  • 20. Inheritance Superclass Rectangle.m #import “Rectangle.h” Superclass Rectangle.h @implementation Rectangle@interface Rectangle: NSObject{ -(id) init int length; { int width; if(self=[super init])} { length = 8;-(int) area; width = 5; }@end return self; } -(int) area { int area1=length * width; } @end
  • 21. InheritanceSubclass printAreaOfRectangle.h#import “Rectangle.h”@interface printAreaOfRectangle: Rectangle-(void) printVal;@end Subclass printAreaOfRectangle.m #import “printAreaOfRectangle.h” @implementation printAreaOfRectangle (void) printVal { NSLog(@”Area = %d”,[self area]); } @end
  • 22. Encapsulation• All the data members are ‘Protected’.• Data is encapsulated, can be accessed only through setter/getter methods.
  • 23. Polymorphismmain{ Window *W = [[Window alloc] init]; View *V = [[view alloc] init]; [W flush]; [V flush];}
  • 24. Dynamic binding + Message Passing main { Window *W = [[Window alloc] init]; View *V = [[view alloc] init]; [W flush]; [V flush]; id anotherObj = W; Dynamic Binding [anotherObj flush]; Message Passing }The flush message is passed to the variable anotherObj that is dynamically bound during runtime.
  • 25. SummaryThe OOPs features that Objective C exhibits are as follows: • Abstraction • Encapsulation • Class • Object • Inheritance • Polymorphism • Message passing • Dynamic Binding
  • 26. Thank you